美文网首页
微信小程序

微信小程序

作者: 夏晶晶绿 | 来源:发表于2020-09-27 17:56 被阅读0次

    字体:

    font-family:Monospaced Number,Chinese Quote,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif!important;
    

    // 条形码,二维码

    var barcode = require('./barcode');
    function convert_length(length) {
        return Math.round(wx.getSystemInfoSync().windowWidth * length / 750);
    }
    function barc(id, code, width, height) {
        barcode.code128(wx.createCanvasContext(id), code, convert_length(width), convert_length(height))
    }
    var qrcode = require('./qrcode');
    function qrc(id, code, width, height) {
        qrcode.api.draw(code, {
              ctx: wx.createCanvasContext(id),
              width: convert_length(width),
                  height: convert_length(height),
                  margin: 0
        })
    }
    module.exports = {
      barcode: barc,
      qrcode: qrc
    }
    
    // 单位rpx
    barcode('id', code, 500, 200); 
    qrcode('id', code, 200, 200); 
    

    相关文章

      网友评论

          本文标题:微信小程序

          本文链接:https://www.haomeiwen.com/subject/iruluktx.html