小程序使用canvas生成二維碼

小程序生成二維碼
weapp.qrcode.min.js放在小程序根目錄下
在須要的頁面的js中引入var qrcode = require('../../weapp.qrcode.min.js');
頁面js:
qrcode({
  width:100,
  height:100,
  canvasId:'myQrcode',
  text:"123",//二維碼內容
  callback:function(){}
});
頁面canvas:
<view>
  <canvas style="width:{{windowWidth*0.5}}px;height:{{windowWidth*0.5}}px;margin:0 auto;" canvas-id="myQrcode"></canvas>
</view>
windowWidth手機屏幕大小,經過wx.getSystemInfo獲取
data:{
  windowWidth:0,
},
wx.getSystemInfo({
  success:(res)=>{
    that.windowWidth:res.windowWidth,
  }
})php

 

抱歉,小程序溫馨不會,知道啥記錄點啥把...git

相關文章
相關標籤/搜索