feat(Form): support using CheckboxGroup

This commit is contained in:
陈嘉涵
2020-02-11 10:00:28 +08:00
parent 48e443d0e2
commit 744cbac987
5 changed files with 36 additions and 3 deletions
+11 -1
View File
@@ -118,6 +118,16 @@ export default createComponent({
formValue() {
return this.children ? this.children.value : this.value;
},
formValueEmpty() {
const { formValue } = this;
if (Array.isArray(formValue)) {
return !formValue.length;
}
return !formValue;
},
},
methods: {
@@ -144,7 +154,7 @@ export default createComponent({
const messages = [];
this.rules.forEach(rule => {
if (rule.required && !this.formValue) {
if (rule.required && this.formValueEmpty) {
messages.push(rule.message);
}
});