调用库文件
https://static.runoob.com/assets/qrcode/qrcode.min.js
菜鸟教程使用:
https://www.runoob.com/w3cnote/javascript-qrcodejs-library.html
页面上要有承载二维码的容器
<div id="qrCode" class="qr-wrapper"></div>
生成二维码的方法:
let qrCodeUrl="https://web.owlive.cn/miniprogram"
handleCreateQrCode(id){
//二维码中携带的链接地址以及参数
let qrUrl = qrCodeUrl + '?qString=' + id;
let that=this;
if(that.qrcode){
that.qrcode.clear();
that.qrcode.makeCode(qrUrl);
}else{
that.qrcode = new QRCode("qrCode", {
text: qrUrl,
width: 300,
height: 300,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
}
}