在小程序页面生成二维码,先看下目录结构,除了四个必备文件之外,引入了三个文件

一个是条形码,一个是二维码

支付宝小程序中将信息生成二维码

在.js文件中引入配置

支付宝小程序中将信息生成二维码

function barc(id, code, width, height){
    barcode.code128(my.createCanvasContext(id), code, convert_length(width), convert_length(height))
}

function qrc(id, code, width, height) {
    qrcode.api.draw(code, {
        ctx: my.createCanvasContext(id),
        width: convert_length(width),
        height: convert_length(height)
    })
}
function convert_length(length) {
    return Math.round(my.getSystemInfoSync().windowWidth * length / 750);
}
var wxbarcode = require('./index.js');

code中是二维码的信息,自己根据需要去修改

支付宝小程序中将信息生成二维码

在axml中展示,如果code中信息改变要重新调用onShow函数

支付宝小程序中将信息生成二维码

相关文章:

  • 2021-04-03
  • 2022-12-23
  • 2022-02-07
  • 2022-01-20
  • 2021-12-09
  • 2022-01-10
  • 2021-07-09
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2021-04-17
  • 2022-12-23
  • 2021-05-05
相关资源
相似解决方案