Commit 0325e1dc authored by hetech's avatar hetech Committed by iamkun

Tabs: rerender when slot changes (#15238)

parent 73ca7be6
......@@ -49,10 +49,8 @@
}
},
watch: {
label() {
this.$parent.$emit('tabLabelChanged');
}
updated() {
this.$parent.$emit('tab-nav-update');
}
};
</script>
......@@ -55,14 +55,14 @@
},
methods: {
calcPaneInstances(isLabelUpdated = false) {
calcPaneInstances(isForceUpdate = false) {
if (this.$slots.default) {
const paneSlots = this.$slots.default.filter(vnode => vnode.tag &&
vnode.componentOptions && vnode.componentOptions.Ctor.options.name === 'ElTabPane');
// update indeed
const panes = paneSlots.map(({ componentInstance }) => componentInstance);
const panesChanged = !(panes.length === this.panes.length && panes.every((pane, index) => pane === this.panes[index]));
if (isLabelUpdated || panesChanged) {
if (isForceUpdate || panesChanged) {
this.panes = panes;
}
} else if (this.panes.length !== 0) {
......@@ -177,7 +177,7 @@
this.setCurrentName('0');
}
this.$on('tabLabelChanged', this.calcPaneInstances.bind(null, true));
this.$on('tab-nav-update', this.calcPaneInstances.bind(null, true));
},
mounted() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment