npm i qrcodejs2
import QRCode from 'qrcodejs2';
<div id="qrcode" v-show="false">
</div>
mounted() {
this.setQrCodeUrl();
},
setQrCodeUrl(){
this.printData.list.forEach(item => {
console.log(item.id);
//二维码
const qrCodeImage = new QRCode(document.getElementById("qrcode"), {
text: item.id,
width: 128,
height: 128,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.L
});
item.imgBase64 = qrCodeImage._oDrawing._elCanvas.toDataURL("image/png");
});
}
<el-image
style="width: 112px; height: 112px"
:src="item.imgBase64"
fit="cover"></el-image>