目前组件只支持根据字符串生成
<template>
<view class="qrcode" v-if="show" @click="hideQrcode">
<uqrcode ref="uQRCode" :mode="mode" :text="text" :size="size" :margin="margin" :background-color="backgroundColor" :foreground-color="foregroundColor" :error-correct-level="errorCorrectLevel" :type-number="typeNumber" :file-type="fileType"></uqrcode>
</view>
</template>
<script>
import uQRCode from '@/components/uqrcode/common/uqrcode'
export default {
data() {
return {
show: true,
mode: 'canvas',
size: 256,
margin: 10,
backgroundColor: '#FFFFFF',
foregroundColor: '#000000',
errorCorrectLevel: uQRCode.errorCorrectLevel.H,
typeNumber: -1,
fileType: 'png',
defaultErrorCorrectLevel: uQRCode.errorCorrectLevel,
qrcodeList: ['我是第一个', '我是第二个', '我是第三个']
};
},
computed: {
text() {
let text = '';
['1', '2', '3'].forEach(item => {
text = `${text}#${item}`;
})
return text;
}
},
methods: {
handleReport() {
this.show = true;
},
hideQrcode() {
this.show = false;
}
}
};
</script>
<style scoped lang="less">
</style>
借助了https://ext.dcloud.net.cn/plugin?id=1287这个包