关于javascript:生成二维码插件qrcode

4次阅读

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

用法:
1. 下包: npm install --save qrcode

2. 导包: import QRCode from 'qrcode'

3. 用包:

<template>
  <div>
    <img :src="src" alt="" />
  </div>
</template>

<script>
import QRCode from 'qrcode'
export default {data () {
    return {src: ''}
  },
  mounted () {
    // QRCode.toDataURL(
    //   'https://vant-contrib.gitee.io/vant/#/zh-CN/popup',
    //   (err, url) => {//     console.log(url)
    //     this.src = url
    //   }
    // )
    QRCode.toDataURL('https://vant-contrib.gitee.io/vant/#/zh-CN/popup').then(
      url => {this.src = url}
    )
  }
}
</script>

<style></style>

链接:
npm-qrcode:https://www.npmjs.com/package/qrcode

正文完
 0