node-qrcode github: https://github.com/soldair/node-qrcode
安装
yarn add qrcode
使用
在需要使用的页面:
<template>
<img :src="qrcode_data">
</template>
<script>
import QRCode from 'qrcode'
export default {
data () {
return {
qrcode_data: ''
}
},
async mounted(){
this.qrcode_data = await QRCode.toDataURL('这是内容');
}
}
QRCode还有很多其他使用方式,比如纯JavaScript浏览器使用,或通过CommonJS等方式,详细可以查看github介绍。