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

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

下载:weapp-qrcode.js  文件

github: https://github.com/Pudon/weapp-qrcode-base64

在项目中引入 weapp-qrcode.js 文件

 

js


const QR = require('../../lib/weapp-qrcode.js'); // 引入 weapp-qrcode

Page({
    /**
     * 页面的初始数据
     */
    data: {
        QrCodeURL:'', // 二维码图片路径
    },

    //在onload 或者onshow上调用二维码的方法触发
    /**
    * 生命周期函数--监听页面显示
    */
    onShow: function () {
     this.drawImg();
    },

    // 二维码
    drawImg: function (){
        let that = this,
            params = "https://www.baidu.com/";  // 二维码参数 此处应注意,参数长度不可过短,长度为5时,二维码扫描出来为空白的。

        var imgData = QR.drawImg(params, {
            typeNumber: 4,          // 密度
            errorCorrectLevel: 'L', // 纠错等级
            size: 800,              // 白色边框
        })
        
        that.setData({
            qrcodeURL: imgData
        })
    },
})

html



<view style="text-align:center;">
    <image style="width:500rpx;height:500rpx;" src="{
   
   { qrcodeURL }}" ></image>
</view>

转自:https://www.cnblogs.com/sanyekui/p/12863604.html

更多相关的:

微信小程序生成二维码工具weapp-qrcode:https://blog.csdn.net/llllladcf/article/details/107637210

微信小程序之生成条形码和二维码:https://blog.csdn.net/huangpb123/article/details/82527344

猜你喜欢

转载自blog.csdn.net/z3287852/article/details/113418064