Skip to content

Commit bea3f8d

Browse files
authored
Merge pull request #383 from DebugIsFalse/checkbox-feature
fix: 兼容checkbox默认值是null的报错问题
2 parents 2ba3c29 + a011b5f commit bea3f8d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

examples/routers/checkbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
data () {
8989
return {
9090
social: ['facebook', 'github'],
91-
fruit: ['苹果'],
91+
fruit: null,
9292
tags: [],
9393
testValue1: null,
9494
testValue2: null,

src/components/checkbox/checkbox.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
},
129129
currentValue () {
130130
if (this.CheckboxGroupInstance) {
131-
return this.CheckboxGroupInstance.modelValue.indexOf(this.label) >= 0;
131+
let modelValue = this.CheckboxGroupInstance.modelValue;
132+
modelValue = Array.isArray(modelValue) ? modelValue : []
133+
return modelValue.indexOf(this.label) >= 0;
132134
} else {
133135
return this.modelValue === this.trueValue;
134136
}

0 commit comments

Comments
 (0)