微信小程序 - 二维码生成工具
下载:weapp-qrcode.js 文件
github: https://github.com/Pudon/weapp-qrcode-base64
在项目中引入 weapp-qrcode.js 文件
js
const app = getApp(); const QR = require('../../lib/weapp-qrcode.js'); // 引入 weapp-qrcode
Page({ /** * 页面的初始数据 */ data: { QrCodeURL:'', // 二维码图片路径
}, // 二维码
drawImg: function (){ let that = this, params = "https://www.baidu.com/"; // 二维码参数
var imgData = QR.drawImg(params, { typeNumber: 4, // 密度
errorCorrectLevel: 'L', // 纠错等级
size: 800, // 白色边框
}) this.setData({ qrcodeURL: imgData }) }, })
html
<view style="text-align:center;">
<image style="width:500rpx;height:500rpx;" src="{{ qrcodeURL }}" ></image>
</view>