npm install -S qrcode
- 页面引入
import QRCode from 'qrcode'
<canvas id="canvas"></canvas>
getCode() {
let _this = this;
_this.$http.post(_this.$http.my_share_card).then(response => {
if (response.code == 1) {
_this.code = response.data;
var canvas = document.getElementById('canvas');
QRCode.toCanvas(canvas, response.data.share_url, function (error) {
if (error) console.error(error)
// console.log('QRCode success!');
})
} else {
_this.$toast(response.msg);
}
})
},