checkbox-age.vue
1 KB
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
<template>
<Checkbox-group :value="handleValue" @input="updateValue" style="width: 350px;" >
<Checkbox label="1">
<span>成人</span>
</Checkbox>
<Checkbox label="2" >
<span>大童</span>
</Checkbox>
<Checkbox label="4">
<span>中童</span>
</Checkbox>
<Checkbox label="3">
<span>小童</span>
</Checkbox>
<Checkbox label="5">
<span>幼童 </span>
</Checkbox>
</Checkbox-group>
</template>
<script>
export default {
name: 'CheckboxAge',
props: ['value'],
data() {
let _this = this;
return {
handleValue: _this.value.split('|')
};
},
methods: {
updateValue(newValue) {
let nValue = newValue.join('|');
this.$emit('input', nValue);
}
},
watch: {
value(newValue) {
this.handleValue = newValue.split('|');
}
}
};
</script>
<style>
</style>