vue js生成图片二维码-- qrcode插件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39192643/article/details/82589188
  1. 在项目中安装依赖
 npm install --save qrcode

2.在项目中使用

<template>
      <div id='code'></div>
      <canvas id="canvas" ref ="canva"></canvas>
</template>

js部分

    <script>
          import QRCode from 'qrcode'
        mounted(){
                this. useqrcode();
      },
      methods: {
                useqrcode(){
                  let canvas = this.$refs.canva;
                  QRCode.toCanvas(canvas, 'http://www.7dingdong.com/#/homepage', function (error) {
                    if (error) console.error(error)
                    console.log('success!');
                  })
           },
       }
  </script>

ok

猜你喜欢

转载自blog.csdn.net/weixin_39192643/article/details/82589188
今日推荐