Skip to content

Commit

Permalink
fix checkbox dynamic init bug (ElemeFE#1511)
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyaaaaa authored and QingWei-Li committed Dec 2, 2016
1 parent 34dbb01 commit 8ba89af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
5 changes: 0 additions & 5 deletions packages/checkbox/src/checkbox-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
};
</script>
Expand Down
23 changes: 17 additions & 6 deletions packages/checkbox/src/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
Expand All @@ -88,7 +105,6 @@
data() {
return {
store: [],
isGroup: false
};
},
Expand All @@ -105,11 +121,6 @@
created() {
this.checked && this.addToStore();
this.$on('initData', data => {
this.store = data;
this.isGroup = true;
this.checked && this.addToStore();
});
}
};
</script>

0 comments on commit 8ba89af

Please sign in to comment.