关于qrcode:qrcode-参数传入默认px-数值转换rem

6次阅读

共计 360 个字符,预计需要花费 1 分钟才能阅读完成。

      var style =
        document.body.currentStyle ||
        document.defaultView.getComputedStyle(document.body, "");
      let fs = style.fontSize.replace("px", "");
      let size = fs * 3.12;
      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
        text: url, // 须要转换为二维码的内容
        width: size,
        height: size,
        colorDark: "#000000",
        colorLight: "#ffffff",
      });

H5 端 rem 自适应 因为 qrcode 参数传入默认 px 导致不能正确居中显示二维码,解决采纳获取 body.fontSize 计算出 px 值传入 qrcode 实现不同屏幕都可居中

正文完
 0