How can I modify the data of a component from another "distant" component? I have the following structure:
Principal
importa a secundario_1
importa a secundario_2
importa a secundario_3
| secundario_3 debe modificar datos de Capa
Capa <---
I just want to modify the abc
Layer value from child_3
data:() => ({
abc: 'hola mundo'
})
I tried with async
and $emit
but it only works for me between parent and child. Thank you
You can use a
EventBus
which helps you to interact between components.What is done is to create a new instance of Vue that will be used only to emit events and receive those events from any other component.
event-bus.js
In your child_3 you import it:
and you emit an event like this:
Then in your Cloak you receive that event:
I leave you the complete code
I hope it helps you!