Skip to content

Commit

Permalink
fix: 兼容checkbox默认值是null的报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
DebugIsFalse committed Aug 7, 2024
1 parent 2ba3c29 commit a011b5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/routers/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
data () {
return {
social: ['facebook', 'github'],
fruit: ['苹果'],
fruit: null,
tags: [],
testValue1: null,
testValue2: null,
Expand Down
4 changes: 3 additions & 1 deletion src/components/checkbox/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@
},
currentValue () {
if (this.CheckboxGroupInstance) {
return this.CheckboxGroupInstance.modelValue.indexOf(this.label) >= 0;
let modelValue = this.CheckboxGroupInstance.modelValue;
modelValue = Array.isArray(modelValue) ? modelValue : []
return modelValue.indexOf(this.label) >= 0;
} else {
return this.modelValue === this.trueValue;
}
Expand Down

0 comments on commit a011b5f

Please sign in to comment.