1.在vue中安装qrcodejs2
npm install --save qrcodejs2
2.在项目中引用qrcodejs2
import QRcode from 'qrcodejs2'
3.使用到项目中
<view id="qrCode" res="qrCodeDiv"></view >
methods:{
bindQRcode(){
new QRcode(this.$refs.qrCodeDiv,{
text:"https://www.baidu.com",
width:200,
height:200,
colorDark: "#333333", //二维码颜色
colorLight: "#ffffff", //二维码背景色
correctLevel: QRcode.CorrectLevel.L//容错率,L/M/H
})
}
}
mountion:{
setTimeout(() => { this.bindQRCode(); }, 100)
}