mirror of https://github.com/ElemeFE/element
Collapse: fix $parent bug when collapse-item is nested in other components (#7675)
* fix collapse bug * fix code stylepull/7679/head
parent
4517e3d9be
commit
cf0197e02a
|
@ -62,6 +62,8 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
inject: ['collapse'],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
title: String,
|
||||||
name: {
|
name: {
|
||||||
|
@ -74,18 +76,13 @@
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isActive() {
|
isActive() {
|
||||||
return this.$parent.activeNames.indexOf(this.name) > -1;
|
return this.collapse.activeNames.indexOf(this.name) > -1;
|
||||||
},
|
},
|
||||||
id() {
|
id() {
|
||||||
return generateId();
|
return generateId();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
|
||||||
'isActive'(value) {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
handleHeaderClick() {
|
handleHeaderClick() {
|
||||||
this.dispatch('ElCollapse', 'item-click', this);
|
this.dispatch('ElCollapse', 'item-click', this);
|
||||||
|
@ -94,9 +91,6 @@
|
||||||
handleEnterClick() {
|
handleEnterClick() {
|
||||||
this.dispatch('ElCollapse', 'item-click', this);
|
this.dispatch('ElCollapse', 'item-click', this);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -25,6 +25,12 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
collapse: this
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
value(value) {
|
value(value) {
|
||||||
this.activeNames = [].concat(value);
|
this.activeNames = [].concat(value);
|
||||||
|
|
Loading…
Reference in New Issue