vue项目使用qrcodejs2生成二维码

1. 安装包

cnpm i qrcodejs2 -S
 
2、使用
 
<div class="codeImg" style="width:1.45rem;height:1.45rem;margin:.15rem auto" id="qrCode"></div>
// 引入
import QRCode from 'qrcodejs2'

methods: {
   let qrcode = new QRCode("qrCode", {
        width: 150,
        height: 150, // 高度
        text: `${location.origin}${location.pathname}/#/?inviteUid=${this.curUser.userId}`,   //要生成二维码的链接(或当前页面地址)
        colorDark : "#000",
        colorLight : "#fff",
      });
  },

 

posted @ 2020-08-20 14:45  潇潇-lucky  阅读(1409)  评论(1编辑  收藏  举报