qrcode插件生成二维码

安装:

npm install --save qrcode

引入:

import QRCode from 'qrcode'

使用;

//触发事件调用下面的方法
// With promises
QRCode.toDataURL('http://jd.com/')
  .then(url => {
    console.log(url)
    this.imrUrl=url;
  })
  .catch(err => {
    console.error(err)
  })

 img使用:

<img v-if="qrcodeUrl" :src="qrcodeUrl" alt="">

.

原文地址:https://www.cnblogs.com/fqh123/p/13846824.html