That's the way I usually do it is to emit an event from the child to the parent component.
Dec 19, 2017
4
Level 14
Reload parent data on child save/update
I'm loading a parent component with user data from the controller. The parent component has a child component for adding a new user, everything works as expected and now I want the parent component's data to re-actively show the newly added user once the post request to axios is complete. I assume this will be achieved with an $emit that triggers a method on the parent to "refresh" the axios.get ? Would this be the right approach?
Level 47
In your child:
someMethod () {
this.$emit('event-name');
}
In the parent:
<child-component
@event-name="handleChildEvent"
>
</child-component>
...
handleChildEvent () {
// do what you need here
}
2 likes
Please or to participate in this conversation.