1. 插件选型
uqrCode
2. 页面部分
template:
<view class="canvas-qrcode-box" style="align-self: center;">
<canvas id="qrcode" canvas-id="qrcode" style="width: 170px;height: 170px;align-self: center;" />
</view>
<script>
var system = uni.getSystemInfoSync();
import uQRCode from '@/uni_modules/Sansnn-uQRCode/components/uqrcode/common/uqrcode.js'
export default {
data() {
return {
vlogId: "",
// screenHeight: system.screenHeight,
screenHeight: system.safeArea.bottom,
statusBarHeight: system.statusBarHeight
}
},
onReady() {
var vlogId = this.vlogId;
var content = {
type: "vlog",
content: vlogId
};
var contentStr = JSON.stringify(content);
uQRCode.make({
canvasId: 'qrcode',
componentInstance: this,
size: 170,
margin: 10,
text: contentStr,
backgroundColor: '#ffffff',
foregroundColor: '#0f0827',
fileType: 'png',
errorCorrectLevel: uQRCode.errorCorrectLevel.H
})
.then(res => {
})
},
onLoad(params) {
var vlogId = params.vlogId;
this.vlogId = vlogId;
},
methods: {
close() {
uni.navigateBack({
delta: 1,
animationType: "slide-out-bottom"
})
},
}
}
</script>
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50