1、qrcode2
This depends on js code.
1. Installation
npm i qrcodejs2 -S
2. Use
<div id="qrcode" ref="qrcode"></div>
this.qr = new QRCode('qrcode', {
width: 150,
height: 150, // 高度
text: this.qrcode // 二维码内容
// render: 'canvas' // 设置渲染方式(有两种方式 table和canvas,默认是canvas)
// background: '#f0f'
// foreground: '#ff0'
})
2、view-qr
This does not need to rely on js code, you can use components directly.
1. Installation
npm install vue-qr --save
2. vue-qr parameters
text
QR code, that is, the page to be redirected after scanning the QR
size
code QR code size QR
margin
code image margin, default 20px
bgSrc
Embedded background image address
logoSrc
Embedded in the QR code center LOGO address
logoScale
Middle image size
dotScale
QR code point size Solid
colorDark
point color (note: it is valid only when set together with colorLight)
colorLight
Blank color (note: it is valid only when set together with colorDark)
autoColor
If true, the main color of the background image will be used as the color of the solid point, ie color Dark, default true
3. Examples
<template>
<div>
<vue-qr
:text="imgUrl"
:size="250"
:logoSrc="logo"
:logoScale="0.2">
</vue-qr>
</div>
</template>
<script>
import VueQr from 'vue-qr'
export default {
name:'',
components:{
VueQr,
},
data() {
return {
imgUrl: 'https://baidu.com',
logo: require('@/assets/tea_128.png'),
}
},
methods:{
},
}
</script>