mirror of https://github.com/ElemeFE/element
fix checkbox dynamic init bug (#1511)
parent
34dbb01c1a
commit
8ba89af678
|
@ -16,12 +16,7 @@
|
||||||
value(value) {
|
value(value) {
|
||||||
this.$emit('change', value);
|
this.$emit('change', value);
|
||||||
this.dispatch('ElFormItem', 'el.form.change', [value]);
|
this.dispatch('ElFormItem', 'el.form.change', [value]);
|
||||||
this.broadcast('ElCheckbox', 'initData', [value]);
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.broadcast('ElCheckbox', 'initData', [this.value]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -72,6 +72,23 @@
|
||||||
} else if (this.model !== null && this.model !== undefined) {
|
} else if (this.model !== null && this.model !== undefined) {
|
||||||
return this.model === this.trueLabel;
|
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() {
|
data() {
|
||||||
return {
|
return {
|
||||||
store: [],
|
|
||||||
isGroup: false
|
isGroup: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -105,11 +121,6 @@
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.checked && this.addToStore();
|
this.checked && this.addToStore();
|
||||||
this.$on('initData', data => {
|
|
||||||
this.store = data;
|
|
||||||
this.isGroup = true;
|
|
||||||
this.checked && this.addToStore();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue