vue-中-使用-import-QRCode--from-'qrcode'

安装

npm install --save qrcode

引入

import QRCode  from 'qrcode'

使用

  let opts = {
        errorCorrectionLevel: "H",//容错级别
        type: "image/png",//生成的二维码类型
        quality: 0.3,//二维码质量
        margin: 5,//二维码留白边距
        width: 200,//宽
        height: 180,//高
        text: "http://www.xxx.com",//二维码内容
        color: {
            dark: "#333333",//前景色
            light: "#fff"//背景色
        }
    };
    let QRCodeMsg = window.location.href; //生成的二维码为URL地址js
    let msg = this.$refs.share
    // 将获取到的数据(val)画到msg(canvas)上
    QRCode.toCanvas(msg, QRCodeMsg, opts, function (error) {
        // conso.log(error)
        console.log(error)
    });

posted @ 2023-02-02 11:02  过好每一天2022  阅读(162)  评论(0)    收藏  举报