import QRCode from 'qrcode'
// import引入可能会导致报错,可以尝试require
// const QRCode = require('qrcode');
// With promises
QRCode.toDataURL('I am a pony!')
.then(url => {
console.log(url)
})
.catch(err => {
console.error(err)
})
Example:
let kh = this.$route.query.kh;
// this.detailQr = new QRCode(document.getElementById("qrGiven"), {//qrcodejs2
// text: kh,
// width: 180,
// height: 180,
// colorDark: '#000000',
// colorLight: '#ffffff',
// correctLevel: QRCode.CorrectLevel.H
// });
QRCode.toDataURL(kh,{margin:1,scale:8,errorCorrectionLevel:'H'})
.then(url => {
this.qrcode = url;
})
.catch(err => {
console.error('err',err)
})
自:https://blog.csdn.net/qq_35432904/article/details/89031001