qrcodejs2
通过npm安装
npm i qrcodejs2 -S
具体实现代码
<template>
<div ref="qrCode"></div>
</template>
<script>
improt QRCode from "qrcodejs2"
data() {
url: ******** // 二维码地址
},
created() {
this.$nextTick(() => {
this.initQrcode()
})
},
methods: {
initQrcode() {
new QRCode(this.$refs.qrCode, {
text: this.url, // 二维码地址
width: 100, // 宽度
height: 100, // 高度
colorDark: "#000000", //二维码颜色
colorLight: '#ffffff' //二维码背景颜色
})
}
}
</script>