Skip to content

Commit a8c050c

Browse files
committed
perf: qrcode
1 parent f18c558 commit a8c050c

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎components/qrcode/qrcode.vue‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<view class="qrcode">
3-
<image class="image" v-if="img != ''" :src="img" :style="{ width: size+'px', height: size + 'px' }"/>
3+
<image class="image" v-if="img" :src="img" :style="{width: sizySync + 'px', height: sizySync + 'px'}"/>
44
</view>
55
</template>
66
<script>
7-
import QR from "./qrcode.js";
7+
import QR from './qrcode.js';
88
export default {
99
name: 'number-box',
1010
props: {
@@ -19,20 +19,19 @@
1919
},
2020
data(){
2121
return{
22-
img:''
22+
img: '',
23+
sizySync: this.size
2324
}
2425
},
25-
onUnload(){
26-
},
2726
methods: {
2827
creatQrcode(){
29-
let val = String(this.val)
30-
if(val == ''){
31-
return false
28+
let val = this.val + '';
29+
if(!val){
30+
return;
3231
}
3332
let img = QR.createQrCodeImg(val, {
3433
size: parseInt(this.size)
35-
})
34+
});
3635
this.img = img;
3736
},
3837
clearQrcode(){
@@ -42,8 +41,8 @@
4241
watch:{
4342
size(newVal, oldVal){
4443
if(newVal != oldVal){
45-
this.size = newVal;
46-
this.creatQrcode()
44+
this.sizySync = newVal;
45+
this.creatQrcode();
4746
}
4847
}
4948
}

0 commit comments

Comments
 (0)