使用uqrcode在UNIAPP VU3 微信小程序 使用UQRCODE 生成二维码
要先在uniapp插件市场下载UQRCODE插件,可直接导入到HBUILDER
然后,template部分
<view>
<uqrcode ref="uqrcode" canvas-id="qrcode"
size=750
sizeUnit='rpx'
:value=code2
:start="false"
:options="{style:'round',margin:50}"></uqrcode>
</view>
script部分
import UQRCodePluginRound from './uqrcode.plugin.round.js'
const {proxy} = getCurrentInstance()
onMounted(() => {
code2.value="https://uqrcode.cn/doc/document/uni-app.html#methods"
proxy.$refs.uqrcode.registerStyle(UQRCodePluginRound)
})
VUE3 setup语法糖里没有this,所以文档里的this.$refs那些都跑不了,所以官方文档里的代码运行不了,
但可以用如图的getCurrentInstance()得到当时页面实例,用它的下