zoukankan      html  css  js  c++  java
  • VUE使用QRcode生成二维码

    安装

    npm install qrcodejs2

    导入

    import QRCode from 'qrcodejs2'

    配置

    1. 编写html,必须需要一个盒子包裹放二维码的div
              <div class="wrapper">
                <div id="qrcode_box" ref="qrCodeUrl"></div>
              </div>
    
    1. methods中建立配置函数
       creatQrCode() {
          const qrcode = new QRCode("qrcode_box", {
             100, //二维码的宽度
            height: 100, //二维码的高度
            text: "https://www.baidu.com/", // 二维码地址
            colorDark: "#000", //二维码颜色
            colorLight: "#fff" //二维码背景颜色
          });
        },
    
    1. 使用,在mounted生命周期中调用函数,必须保证“盒子”先渲染完成,使用this.$nextTick()
        this.$nextTick(() => {
          this.creatQrCode();
        });
    
  • 相关阅读:
    for循环
    3.9 作业
    while循环
    深浅拷贝
    条件与判断
    可变与不可变
    与用户交互与运算符
    垃圾回收机制
    【AC自动机】文本生成器
    【AC自动机】最短母串
  • 原文地址:https://www.cnblogs.com/cqkjxxxx/p/15035958.html
Copyright © 2011-2022 走看看