微信小程序中生成二维码

使用weapp-qrcode.js

链接:https://pan.baidu.com/s/1j0qjoYvl6pCK8EzSsfks9g 提取码:8wxe

微信小程序中生成二维码
<canvas class="canvas-code" canvas-id="myQrcode" :style="{ width: qrcode_w + ‘px‘, height: qrcode_w + ‘px‘ }" />import QRCode from ‘../../utils/weapp-qrcode.js‘;getEwm() { const W = wx.getSystemInfoSync().windowWidth; const rate = 750.0 / W; // 160rpx 在6s上为 80px this.qrcode_w = 160 / rate; new QRCode(‘myQrcode‘, { text: ‘你的链接‘, width: this.qrcode_w, height: this.qrcode_w, colorDark: ‘#000000‘, colorLight: ‘#ffffff‘, padding: 2, // 生成二维码四周自动留边宽度,不传入默认为0 correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度 callback: res => { console.log(res.path); } }); }

  

相关文章