index_1.vue
718 Bytes
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
<template>
<u-switch v-model="innerValue" :active-value="activeValue" :inactive-value="inactiveValue" :disabled="disabled"
@change="onChange"></u-switch>
</template>
<script>
export default {
name: 'ncc-switch',
model: {
prop: 'value',
event: 'input'
},
props: {
value: {
default: 0
},
activeValue: {
default: 1
},
inactiveValue: {
default: 0
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
innerValue: false
}
},
watch: {
value(val) {
this.innerValue = !!val
}
},
created() {
this.innerValue = !!this.value
},
methods: {
onChange(value) {
this.$emit('input', value)
}
}
}
</script>