使用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); } }); }