[Vuejs]-How to update the props in vue when the grandchild file has send the succeed PUT request

1👍

Use an emit. Tell the parent component to update via another GET request or just pass the data back directly.

Child Method:

notifyParent () {
     this.$emit('updateProfile')
}

Parent Template:

<ChildComponent v-on:updateProfile="someMethod"/>

Parent Method:

someMethod () {
     //GET request or whatever
}

More details here: https://v2.vuejs.org/v2/guide/components-custom-events.html

👤Arc

0👍

The keyword here is eventBus, you need an eventBus to $emit an event changing the data in the parent component from the grandchild component. If you only need to change up the data 1 layer instead of 2 in this case, you only need custom event + $emit, without the eventBus. But as it’s greater than 2 layers, you need eventBus, or even more relegent ways to do state management.

Leave a comment