3π
β
Itβs not a good practice to use $parent
, but instead of that you could use emit
to send an event from the child component to run some method in parent one :
in the Child component emit the event with your payload :
swapComponent: function (component) {
this.$emit("swap-component",this.components[component])
}
in parent one:
<DrawerComponent @swap-component="displayComponent"></DrawerComponent>
and change div
to component
in
<div ref="ComponentDisplay" :is="currentComponent"></div>
Source:stackexchange.com