微信小程序生成二维码

最近开发中遇到需要在微信前台显示二维码,又不想在后台生成,所以选用基于img,base64输出二维码

js中:
var QR = require( "../../../utils/wxqrcode.js");


that.setData({
imgData: QR.createQrCodeImg(res.data, { size: 300 })
})
wxml中:

< view class= "modal-content">
< image src= "{{imgData}}" class= "qrcode"></ image >

</ view >

wxqrcode.js下载 

猜你喜欢

转载自blog.csdn.net/qq_27721169/article/details/80435699