赞
踩
先npm install qrcodejs2
后导入
import QRCode from "qrcodejs2";
<div class="QRcode" id="qrcode">
<div style="margin: 0 0 20px 0">扫一扫</div>
<div ref="qrcode"></div>
</div>
等DOM更新完成 生成二维码
this.$nextTick(() => {
// 清除qrcode
if (this.$refs.qrcode.innerHTML) {
this.$refs.qrcode.innerHTML = "";
}
new QRCode(this.$refs.qrcode, {
text: "此处是二维码的文本",
width: 220,
height: 220,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H,
});
});
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。