diff --git a/packages/checkbox/src/checkbox-group.vue b/packages/checkbox/src/checkbox-group.vue index 49932635d..fd0bb3edf 100644 --- a/packages/checkbox/src/checkbox-group.vue +++ b/packages/checkbox/src/checkbox-group.vue @@ -16,12 +16,7 @@ value(value) { this.$emit('change', value); this.dispatch('ElFormItem', 'el.form.change', [value]); - this.broadcast('ElCheckbox', 'initData', [value]); } - }, - - mounted() { - this.broadcast('ElCheckbox', 'initData', [this.value]); } }; diff --git a/packages/checkbox/src/checkbox.vue b/packages/checkbox/src/checkbox.vue index 5b1e8c4f2..42a9eea9a 100644 --- a/packages/checkbox/src/checkbox.vue +++ b/packages/checkbox/src/checkbox.vue @@ -72,6 +72,23 @@ } else if (this.model !== null && this.model !== undefined) { return this.model === this.trueLabel; } + }, + + isGroup() { + let parent = this.$parent; + while (parent) { + if (parent.$options.componentName !== 'ElCheckboxGroup') { + parent = parent.$parent; + } else { + this._checkboxGroup = parent; + return true; + } + } + return false; + }, + + store() { + return this._checkboxGroup.value; } }, @@ -88,7 +105,6 @@ data() { return { - store: [], isGroup: false }; }, @@ -105,11 +121,6 @@ created() { this.checked && this.addToStore(); - this.$on('initData', data => { - this.store = data; - this.isGroup = true; - this.checked && this.addToStore(); - }); } };