Vue 3 Sibling Component Communication

Viewed 2288

I'm new to vue. I'm wondering how could I achieve: A click event happened in my one of my sibling1 component, and then how can I call another function to my sibling2 component after that event happened?

I tried to pass the data from sibling 1 to parent by using emit and then pass the data back to sibling2 from the parent by props, but I'm kinda confused on how could a prop has made certain function to happen?

Thank you and I appreicate it!

2 Answers

use Vuex it handles better, this man explains well youtube

Without seeing your actual code, all I can suggest is to watch the relevant prop in your sibling component and invoke the function when the prop changes.

props object itself is reactive, and if the particular prop you are using is part of the parent component’s data, it is a reactive object as well so you can even watch it deeply

Related