微信小程序 - 二维码生成工具 weapp-qrcode


微信小程序 - 二维码生成工具

下载: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>

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM