vue+QRCode 将url生成一个二维码图片地址

使用qrcode.js库

const QRCode = require('qrcode');
const url = "https://chat.deepseek.com/";

// 生成DataURL格式的二维码图片
QRCode.toDataURL(url, function(err, url) {
  console.log(url); // 这里会输出二维码的base64图片地址
});

使用qrcodejs2库

import QRCode from 'qrcodejs2';

  <el-table-column
            align="center"
            label="二维码"
            prop="preparationDate"
            width="140"
          >
            <template slot-scope="scope">
              <div :ref="`codeImg${scope.row.infoId}`">
                {{ getCode(scope.row) }}
              </div>
            </template>
 </el-table-column>
 // methodes里面
    getCode(row) {
      let QRlink = row.imgUrl && row.imgUrl[0] ? row.imgUrl[0].value : "";

      this.$nextTick(() => {
        if (QRlink) {
          let codeImg = this.$refs[`codeImg${row.infoId}`];
          codeImg.innerHTML = "";
          new QRCode(codeImg, {
            text: QRlink,
            width: 120,
            height: 120,
            colorDark: "#000000",
            colorLight: "#ffffff",
            correctLevel: QRCode.CorrectLevel.H,
          });
          //将生成的二维码路径复制给data的QRImgUrl
        }
      });
    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值