先到 https://github.com/davidshimjs/qrcodejs 下载一个 weapp-qrcode.js
然后放在utils文件夹下
在要生成二维码的页面js最上面导入该js
var QRCode = require('../../utils/weapp-qrcode.js')
var qrcode;
js代码:
qrcode = new QRCode('canvas', { // usingIn: this, text: "你要生成的内容", width: 250, height: 250, colorDark: "black", colorLight: "white", correctLevel: QRCode.CorrectLevel.H });
wxml代码: