Commit 01b8d340c56dd857887a3d01e403fdd867463bf6
1 parent
545aa32b
fixed #778
Showing
2 changed files
with
19 additions
and
86 deletions
Show diff stats
examples/routers/checkbox.vue
1 | 1 | <template> |
2 | 2 | <div> |
3 | - <Checkbox v-model="single" @on-change="s">Checkbox</Checkbox> | |
4 | - {{ single }} | |
5 | - <div @click="single = !single">single-change</div> | |
6 | - <br> | |
7 | - {{ social }} | |
8 | - <Checkbox-group v-model="social" @on-change="s"> | |
9 | - <Checkbox label="twitter"> | |
10 | - <Icon type="social-twitter"></Icon> | |
11 | - <span>Twitter</span> | |
12 | - </Checkbox> | |
13 | - <Checkbox label="facebook"> | |
14 | - <Icon type="social-facebook"></Icon> | |
15 | - <span>Facebook</span> | |
16 | - </Checkbox> | |
17 | - <Checkbox label="github"> | |
18 | - <Icon type="social-github"></Icon> | |
19 | - <span>Github</span> | |
20 | - </Checkbox> | |
21 | - <Checkbox label="snapchat"> | |
22 | - <Icon type="social-snapchat"></Icon> | |
23 | - <span>Snapchat</span> | |
24 | - </Checkbox> | |
25 | - </Checkbox-group> | |
26 | - <br> | |
27 | - <div @click="c">修改1</div> | |
28 | - {{ fruit }} | |
29 | 3 | <Checkbox-group v-model="fruit"> |
30 | - <Row> | |
31 | - <i-col span="8"> | |
32 | - <Checkbox label="香蕉"></Checkbox> | |
33 | - </i-col> | |
34 | - <i-col span="8"> | |
35 | - <Checkbox label="苹果"></Checkbox> | |
36 | - </i-col> | |
37 | - <i-col span="8"> | |
38 | - <Checkbox label="西瓜"></Checkbox> | |
39 | - </i-col> | |
40 | - </Row> | |
41 | - </Checkbox-group> | |
42 | - <br><br> | |
43 | - <div style="border-bottom: 1px solid #e9e9e9;padding-bottom:6px;margin-bottom:6px;"> | |
44 | - <Checkbox | |
45 | - :indeterminate="indeterminate" | |
46 | - v-model="checkAll" | |
47 | - @click.prevent.native="handleCheckAll">全选</Checkbox> | |
48 | - </div> | |
49 | - <Checkbox-group v-model="checkAllGroup" @on-change="checkAllGroupChange"> | |
50 | - <Checkbox label="香蕉"></Checkbox> | |
51 | - <Checkbox label="苹果"></Checkbox> | |
52 | - <Checkbox label="西瓜"></Checkbox> | |
4 | + <Checkbox v-for="item in tags" :label="item.label"></Checkbox> | |
53 | 5 | </Checkbox-group> |
6 | + <div>{{ fruit }}</div> | |
54 | 7 | </div> |
55 | 8 | </template> |
56 | 9 | <script> |
... | ... | @@ -59,45 +12,23 @@ |
59 | 12 | return { |
60 | 13 | social: ['facebook', 'github'], |
61 | 14 | fruit: ['苹果'], |
62 | - single: false, | |
63 | - indeterminate: true, | |
64 | - checkAll: false, | |
65 | - checkAllGroup: ['香蕉', '西瓜'] | |
15 | + tags: [] | |
66 | 16 | } |
67 | 17 | }, |
68 | - methods: { | |
69 | - c () { | |
70 | - this.social.splice(0, 1) | |
71 | - }, | |
72 | - s (d) { | |
73 | - console.log(d) | |
74 | - }, | |
75 | - handleCheckAll () { | |
76 | - if (this.indeterminate) { | |
77 | - this.checkAll = false; | |
78 | - } else { | |
79 | - this.checkAll = !this.checkAll; | |
80 | - } | |
81 | - this.indeterminate = false; | |
82 | - | |
83 | - if (this.checkAll) { | |
84 | - this.checkAllGroup = ['香蕉', '苹果', '西瓜']; | |
85 | - } else { | |
86 | - this.checkAllGroup = []; | |
87 | - } | |
88 | - }, | |
89 | - checkAllGroupChange (data) { | |
90 | - if (data.length === 3) { | |
91 | - this.indeterminate = false; | |
92 | - this.checkAll = true; | |
93 | - } else if (data.length > 0) { | |
94 | - this.indeterminate = true; | |
95 | - this.checkAll = false; | |
96 | - } else { | |
97 | - this.indeterminate = false; | |
98 | - this.checkAll = false; | |
99 | - } | |
100 | - } | |
18 | + mounted () { | |
19 | + setTimeout(() => { | |
20 | + this.tags = [ | |
21 | + { | |
22 | + label: '香蕉' | |
23 | + }, | |
24 | + { | |
25 | + label: '苹果' | |
26 | + }, | |
27 | + { | |
28 | + label: '西瓜' | |
29 | + } | |
30 | + ] | |
31 | + }, 1000); | |
101 | 32 | } |
102 | 33 | } |
103 | 34 | </script> | ... | ... |
src/components/checkbox/checkbox.vue