<template>
<div>
<button @click="qrcodeScan">显示</button>
<div id="qrcode" ref="qrcode"></div>
</div>
</template>
<script>
import QRCode from 'qrcodejs2'
export default {
data() {
return {}
},
methods: {
qrcodeScan() {//生成二维码
this.$nextTick(() => {
new QRCode(this.$refs.qrcode, {
width: 200, // 二维码宽度
height: 200, // 二维码高度
text: 'https://mp.csdn.net' //登录的地址
})
})
}
},
components: {}
}
</script>
<style lang="less" scoped>
</style>
也可以放在Dialog中显示