diff --git a/src/components/checkbox/Checkbox.vue b/src/components/checkbox/Checkbox.vue index b32fa4f93..a813d38d9 100644 --- a/src/components/checkbox/Checkbox.vue +++ b/src/components/checkbox/Checkbox.vue @@ -37,11 +37,16 @@ export default { if (!this.disabled) { let newModelValue; - if (this.checked) - newModelValue = this.modelValue.filter(val => !ObjectUtils.equals(val, this.value)); - else - newModelValue = this.modelValue ? [...this.modelValue, this.value] : [this.value]; - + if (Array.isArray(this.modelValue)) { + if (this.checked) + newModelValue = this.modelValue.filter(val => !ObjectUtils.equals(val, this.value)); + else + newModelValue = this.modelValue ? [...this.modelValue, this.value] : [this.value]; + } + else { + newModelValue = !this.modelValue; + } + this.$emit('click', event); this.$emit('input', newModelValue); this.$emit('change', event); @@ -59,7 +64,7 @@ export default { }, computed: { checked() { - return this.modelValue != null && ObjectUtils.contains(this.value, this.modelValue); + return Array.isArray(this.modelValue) ? ObjectUtils.contains(this.value, this.modelValue) : this.modelValue; } } } diff --git a/src/views/checkbox/CheckboxDemo.vue b/src/views/checkbox/CheckboxDemo.vue index 526e2e2aa..d72fe553d 100644 --- a/src/views/checkbox/CheckboxDemo.vue +++ b/src/views/checkbox/CheckboxDemo.vue @@ -9,6 +9,10 @@