微信小程序 地址 生成二维码显示

使用的是 weapp-qrcode,源代码地址

https://github.com/tomfriwel/weapp-qrcode
效果图
在这里插入图片描述

项目中的代码

1.js页面引入js(js在github上自己下载)

在这里插入图片描述

2.js页面 定义一个方法

//this.data.codeText是图片的地址

 data: {
    reqUrl: url.base,
    urlBase: url.urlBase,
    qrcode_w: qrcode_w,
    headImg:"",//头像
    name: "",  //昵称
    invitecode: "", //邀请码
    qrcodeURL: "", //二维码
    codeText: ""  //二维码内容地址
  },
  
  drawImg: function () {
    console.log(qrcode_w);
    var imgData = qRCode.drawImg(this.data.codeText, {
      typeNumber: 5,
      errorCorrectLevel: 'M',
      width: qrcode_w,
      height: qrcode_w,
      canvasId: 'myQrcode'
    })
    this.setData({
      qrcodeURL: imgData
    })
  }

wxml中的使用

 <image src="{{qrcodeURL}}" mode="" class="" id="" style="width:100%;height:450rpx;" background-size="cover"></image>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值