需引入weapp-qrcode.js
下载https://blog-static.cnblogs.com/files/-tiantian/weapp-qrcode.js,点开链接按 ctrl + s 保存到对应的位置
页面引入
let drawQrcode = require("../../js/weapp-qrcode")
wxml
<canvas style="width: 600rpx; height: 600rpx;" canvas-id="myQrcode"></canvas>
js
onLoad: function (options) {
this.ewmChange()
},
ewmChange(){
let size = {}
size.w = wx.getSystemInfoSync().windowWidth / 750 * 600
size.h = size.w
var that = this
drawQrcode({
width: size.w,
height: size.h,
canvasId: 'myQrcode',
// ctx: wx.createCanvasContext('myQrcode'),
text: '123456', //二维码参数
// v1.0.0+版本支持在二维码上绘制图片
})
},