vue一维码,二维码生成

一.条形码
安装依赖:

npm install jsbarcode --save

案例

<template>
    <canvas id="barCode"></canvas>
</template>
<script>
import JsBarcode from 'jsbarcode'
export default {
   
  data () {
   
    return {
   
      bindBarCode (selector, data = '1129867908') {
   
        JsBarcode(selector, data, {
   
          background: '#eee',
          displayValue: false,
          // width: 1, // 
          height: 80, // 一维码的高度
          margin: 10 // 一维码与容器的margin
        })
      }
    }
  },
  mounted () {
   
    this.bindBarCode('#barCode')
  }
}
</script>

一.二维码

npm install --save qrcode

案例

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

<script>
import QRCode from 'qrcode'
export default {
   
  data() {
   
    return {
   
    	QRImgUrl: '',
    	QRlink:'www.xxx.com'
    }
  },
  created() {
   
    this.getQRcode('888')
  },
  methods: {
   
  	getQRcode(v){
   
  		QRCode.toDataURL(v, {
    errorCorrectionLevel: 'L', margin: 2, width: 128 }, (err, url) => {
   
          if (err) throw err
          this.QRImgUrl= url
        })
  	}
  }
}
</script>

</script>



相关推荐

  1. vue生成

    2024-01-13 07:02:04       38 阅读
  2. SpringBoot生成

    2024-01-13 07:02:04       15 阅读
  3. 生成

    2024-01-13 07:02:04       35 阅读
  4. vue,uniapp生成

    2024-01-13 07:02:04       40 阅读
  5. vue,uniapp生成

    2024-01-13 07:02:04       40 阅读
  6. Vue生成Canvas

    2024-01-13 07:02:04       35 阅读
  7. vue qrcode生成

    2024-01-13 07:02:04       21 阅读
  8. 自己生成

    2024-01-13 07:02:04       35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-13 07:02:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-13 07:02:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-13 07:02:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-13 07:02:04       20 阅读

热门阅读

  1. 【学习笔记】神经网络相关

    2024-01-13 07:02:04       36 阅读
  2. 构建神经网络的流程是什么?

    2024-01-13 07:02:04       30 阅读
  3. vue3中的hook公共函数封装及运用

    2024-01-13 07:02:04       36 阅读
  4. 二Dockerfile实战

    2024-01-13 07:02:04       32 阅读
  5. 【算法题】50. Pow(x, n)

    2024-01-13 07:02:04       34 阅读
  6. 【docker】Docker Stack 详细使用及注意事项

    2024-01-13 07:02:04       33 阅读
  7. Unity 鼠标点击或触摸任意拖动UGUI的方法

    2024-01-13 07:02:04       33 阅读
  8. 50天精通Golang(第15天)

    2024-01-13 07:02:04       32 阅读
  9. mysql undo log、redo log、binlog、mvcc、Buffer Pool的关系

    2024-01-13 07:02:04       33 阅读