<div>
<div class="qrcode-pic" ref=codeitem style="margin-top: 15px;"></div>//生成二維碼顯示地方
<button @click='qrCode'>點(diǎn)擊生成二維碼</button>
</div>
js部分
data(){
return{
qrData:[{
url:"127........."
},{
url:"127........."
}]
}
}
qrCode(){
this.$nextTick(()=>{//必須寫(xiě)在this.$nextTick否則會(huì)報(bào)錯(cuò).
this.qrData.forEach((item,index)=>{
let code = item.url;
this.$refs.codeitem.innerhtml="";
new QRCode(this.$refs.codeitem[index], {
text: code, //轉(zhuǎn)成二維碼的內(nèi)容
width:150,
height: 150
})
})
})
}