安装插件
npm i qrcodejs2 -S
使用页面
<template>
<div id="qrcode" style="width:200px;height:200px;margin-top:30px" ref="qrCodeUrl"></div>
<template>
<script>
import QRCode from 'qrcodejs2'
mounted () {
this.creatQrCode();
},
mothods:{
getSettleQrcode(){
const codeHtml = document.getElementById("qrcode");
codeHtml.innerHTML = "";
var qrcode= new QRCode(this.$refs.qrCodeUrl, {
text: 'www.baidu.com',
width: 100,
height: 100,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H
})
}
},
<script>