使用canvas生成二维码

1.首先引入uQRCode.js
qrFun: function(text) {
let that = this
this.qrShow = true
uQRCode.make({
canvasId: ‘qrcode’,
componentInstance: this,
text: text,
size: 125,
margin: 6,
backgroundColor: ‘#ffffff’,
foregroundColor: ‘#000000’,
fileType: ‘png’,
errorCorrectLevel: uQRCode.errorCorrectLevel.H,
success: res => {
base64ToPath(res)
.then(path => {
that.img = path
})
.catch(error => {
console.error(error)
})
}
})
},