1
2
3
4
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| <template>
| <view>
| <uni-icons class="p-icon"
| type="scan"
| size="16"
| color="#a6a6a6"
| @click="scanCode"
| >
| </uni-icons>
| <input v-model="data" @input="change" >
| </view>
| </template>
|
| <script>
| export default {
| name:"zzz",
| data() {
| return {
| data: ''
| };
| },
| props: {
| value: {
| type: String,
| default: ""
| },
| },
| watch: {
| data(val){
| if (val.length != 8) {
| setTimeout(()=>{
| this.data = ''
| // this.value = '9999'
| this.$emit('input','')
| },0)
| } else {
| this.$emit('input',val)
| }
| },
| value(val) {
| this.data = val
| }
| },
| created() {
| this.data = this.value
| },
| methods: {
| change() {
| this.$emit('change1')
| },
| scanCode() {
| let _this = this
| uni.scanCode({
| onlyFromCamera: true,
| success(res) {
| _this.$parent.scanCode(res.result)
| _this.data = res.result
| _this.value = res.result
| console.log('扫到了');
| console.log(res);
| }
| })
| }
| }
| }
| </script>
|
| <style>
|
| </style>
|
|