From f65e9be5658e3d61b6ae0e7276e90140814898f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=81=8F?= Date: Wed, 4 Jan 2017 11:09:10 +0800 Subject: [PATCH] update checkboxGroup update checkboxGroup --- src/components/checkbox/checkbox-group.vue | 1 + src/components/checkbox/checkbox.vue | 1 + test/routers/form.vue | 31 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/checkbox/checkbox-group.vue b/src/components/checkbox/checkbox-group.vue index 4fe26494..74f99002 100644 --- a/src/components/checkbox/checkbox-group.vue +++ b/src/components/checkbox/checkbox-group.vue @@ -40,6 +40,7 @@ change (data) { this.model = data; this.$emit('on-change', data); + this.$dispatch('on-form-change', data); } }, watch: { diff --git a/src/components/checkbox/checkbox.vue b/src/components/checkbox/checkbox.vue index 3f126fcb..853925ad 100644 --- a/src/components/checkbox/checkbox.vue +++ b/src/components/checkbox/checkbox.vue @@ -94,6 +94,7 @@ this.$parent.change(this.model); } else { this.$emit('on-change', this.checked); + this.$dispatch('on-form-change', this.checked); } }, updateModel () { diff --git a/test/routers/form.vue b/test/routers/form.vue index 7e93294d..6d322fd7 100644 --- a/test/routers/form.vue +++ b/test/routers/form.vue @@ -30,6 +30,26 @@ + + + + + Twitter + + + + Facebook + + + + Github + + + + Snapchat + + + 提交 @@ -45,7 +65,8 @@ mail: '', passwd: '', single: false, - group: '' + group: '', + checkboxgroup: [] }, rules: { mail: [ @@ -68,6 +89,14 @@ { required: true, message: '请单选组' } + ], + checkboxgroup: [ + { + required: true, message: '至少选择2个', min: 2, type: 'array', + }, + { + required: true, message: '至多选择3个', max: 3, type: 'array' + } ] } }