8***@qq.com
8***@qq.com
  • 发布:2023-02-03 16:29
  • 更新:2023-02-03 16:29
  • 阅读:592

uniapp 使用qrcode生成二维码,h5可以显示二维码,微信小程序不显示二维码

分类:uni-app

uniapp 使用qrcode生成二维码,h5可以显示二维码,微信小程序不显示二维码,这个问题困扰了很久,在hbuild上可以显示二维码,发布到微信小程序,在微信开发者工具中不显示二维码,真机调试也不显示。代码如下

import drawQrcode  from '@/utils/weapp.qrcode.min.js';  
    import tuiNoData from "@/components/thorui/tui-no-data/tui-no-data.vue";  
    export default {  
        name: 'qrcodeinfo',  
        components:{  
            tuiNoData  
        },  
        data() {  
            return {  
                code: true,  
                qrcode_w:200,  
                text:"sss",  
                desc:{  
                    items:{  
                        '0':"数据采集",  
                        '1':"扫描"  
                    },  
                    length:2  
                }  
            }  
        },  

        onLoad:function() {  
            this.qrcode(this.text,'qrcode');  
        },  
        methods: {  
            // 二维码生成工具  
            qrcode(text, canvasId) {  

                    var that =this  
                    const ctx = wx.createCanvasContext(canvasId, this);  
                     drawQrcode({  
                        width: this.qrcode_w,  
                        height: this.qrcode_w,  
                        x: 0,  
                        y: 0,  
                        ctx:ctx,  
                        canvasId: canvasId,  
                        typeNumber: 5,   
                        text: text,   
                        background: '#FFFFFF',   
                        foreground: '#000000',   
                        correctLevel: 2,   
                        callback(e) {  
                            console.log('生成二维码: ', e)  
                        }  
                     });  
            }  

        }  
    }
2023-02-03 16:29 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复