Commit f65e9be5658e3d61b6ae0e7276e90140814898f2

Authored by 梁灏
1 parent 578ca325

update checkboxGroup

update checkboxGroup
src/components/checkbox/checkbox-group.vue
... ... @@ -40,6 +40,7 @@
40 40 change (data) {
41 41 this.model = data;
42 42 this.$emit('on-change', data);
  43 + this.$dispatch('on-form-change', data);
43 44 }
44 45 },
45 46 watch: {
... ...
src/components/checkbox/checkbox.vue
... ... @@ -94,6 +94,7 @@
94 94 this.$parent.change(this.model);
95 95 } else {
96 96 this.$emit('on-change', this.checked);
  97 + this.$dispatch('on-form-change', this.checked);
97 98 }
98 99 },
99 100 updateModel () {
... ...
test/routers/form.vue
... ... @@ -30,6 +30,26 @@
30 30 </Radio>
31 31 </Radio-group>
32 32 </form-item>
  33 + <form-item label="checkbox-g" prop="checkboxgroup">
  34 + <Checkbox-group :model.sync="form.checkboxgroup">
  35 + <Checkbox value="twitter">
  36 + <Icon type="social-twitter"></Icon>
  37 + <span>Twitter</span>
  38 + </Checkbox>
  39 + <Checkbox value="facebook">
  40 + <Icon type="social-facebook"></Icon>
  41 + <span>Facebook</span>
  42 + </Checkbox>
  43 + <Checkbox value="github">
  44 + <Icon type="social-github"></Icon>
  45 + <span>Github</span>
  46 + </Checkbox>
  47 + <Checkbox value="snapchat">
  48 + <Icon type="social-snapchat"></Icon>
  49 + <span>Snapchat</span>
  50 + </Checkbox>
  51 + </Checkbox-group>
  52 + </form-item>
33 53 <form-item>
34 54 <i-button type="primary" @click="onSubmit('form')">提交</i-button>
35 55 </form-item>
... ... @@ -45,7 +65,8 @@
45 65 mail: '',
46 66 passwd: '',
47 67 single: false,
48   - group: ''
  68 + group: '',
  69 + checkboxgroup: []
49 70 },
50 71 rules: {
51 72 mail: [
... ... @@ -68,6 +89,14 @@
68 89 {
69 90 required: true, message: '请单选组'
70 91 }
  92 + ],
  93 + checkboxgroup: [
  94 + {
  95 + required: true, message: '至少选择2个', min: 2, type: 'array',
  96 + },
  97 + {
  98 + required: true, message: '至多选择3个', max: 3, type: 'array'
  99 + }
71 100 ]
72 101 }
73 102 }
... ...