<div class="qrBox">
<div id="qrCode" ref="qrCodeDiv"></div>
<img class="qrLogo" src="@/assets/logo.jpg" />
<div class="qrButBox" v-if="qrButBox === true">
<button @click="newQrimg">点击重新获取二维码</button>
</div>
</div>
created () {
this.$nextTick(function () {
this.BindQRCode()
})
this.timeQR()
},
methods: {
newQrimg () {
this.BindQRCode()
this.qrButBox = false
this.timeQR()
},
timeQR () {
var _this = this
setTimeout(function () {
_this.$nextTick(function () {
_this.qrButBox = true
})
}, 3000)
},
BindQRCode () {
new QRCode(this.$refs.qrCodeDiv, {
text: 'https://www.baidu.com/',
width: 180,
height: 180,
colorDark: '#333', // 二维码颜色
colorLight: '#fff', // 二维码背景色
correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
})
},
}
vue 生成二维码
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 1、安装插件 npm install qrcodejs2 --save 2、页面引用 import QRCode ...