1.引入
import vueQr from 'vue-qr'
2.html
<vue-qr
ref="Qrcode"
:text="地址"
:margin="15"
:size="500"
:width="290"
/>
<el-button
type="success"
@click="getQrCode('Qrcode', '二维码')"
>下载二维码</el-button>
3.js
// refName ref名称 name下载文件名称
getQrCode(refName, name) {
const iconUrl = this.$refs[refName].$el.src
const a = document.createElement('a')
const event = new MouseEvent('click')
a.download = name
a.href = iconUrl
a.dispatchEvent(event)
}
4.常用属性介绍