二维码生成库

qrcode

QRCode.js 是一个用于生成二维码的 JavaScript 库。主要是通过获取 DOM 的标签,再通过 HTML5 Canvas 绘制而成,不依赖任何库。

1.使用

下载

需要引入它的js文件

http://davidshimjs.github.io/qrcodejs/

2.用法

<template>
  <div>
    <div id="qrcode"></div>
  </div>
</template>
<script>
let moment = require("moment");
export default {
  data() {
    return {};
  },
  mounted() {
    console.log(moment().format("Y-MM-DD"));
    this.createqrcode();
  },
  methods: {
    createqrcode() {

    //   new QRCode(document.getElementById("qrcode"), "http://www.runoob.com");

    let op = document.getElementById("qrcode");
      var qrcode = new QRCode(op, {
        text: "http://www.runoob.com",
        width: 128,
        height: 128,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
      });
    }
  }
};
</script>
<style lang="scss" scoped>
#qrcode{
    width: 100px;
    height: 100px;
    background: red;
}
</style>

猜你喜欢

转载自blog.csdn.net/yang939207690/article/details/107517453