npm install --save qrcode下载依赖
<template>
<div class="sh-v">
<img :src="QRImgUrl"/>
</div>
</template>
<script>
import QRCode from 'qrcode'
export default {
data(){
return {
QRImgUrl: '',
QRlink:'www.baidu.com',
}
},
created(){
},
mounted(){
QRCode.toDataURL(this.QRlink, { errorCorrectionLevel: 'L', margin: 2, width: 128 }, (err, url) => {
if (err) throw err
this.QRImgUrl= url
})
},
methods:{
}
}
</script>