【VUE】vue项目中使用qrcode生成二维码

npm install qrcode
import QRCode from 'qrcode'
  export default{
    data(){
      return {
        codes:''
      }
    },
    components: {
      QRCode: QRCode
    },
    methods:{
      useqrcode(){
        var canvas = document.getElementById('canvas')

        QRCode.toCanvas(canvas, 'http://www.baidu.com', function (error) {
          if (error) console.error(error)
          console.log('success!');
        })
      }
    },
    mounted(){
      this.useqrcode();
    }
  }
转载于 https://www.cnblogs.com/superAnny/p/8316380.html

你可能感兴趣的:(前端,vue,qrcode)