Skip to content

Commit

Permalink
Merge pull request #383 from DebugIsFalse/checkbox-feature
Browse files Browse the repository at this point in the history
fix: 兼容checkbox默认值是null的报错问题
  • Loading branch information
icarusion authored Aug 7, 2024
2 parents 2ba3c29 + a011b5f commit bea3f8d
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 bea3f8d

Please sign in to comment.