I got vue app with following structure:
"blackout" component for poping up modals and router-view for all sub-menues.
Those are sibling (located at one level).
<blackout v-if="this.popup.currentPopup"></blackout>
....
<router-view class="folder">
...child-component with get request displaying data
</router-view>
There is a saving button for sending data with post method in dynamic loaded component at "blackout"(:is directive). After click save button I need to re-fetch data at "router-view"’s child component.
My question is how to notify sibling component that sibling-modal have made a post request and was closed.
After some researches I find out some: event-bus (antipattern), watching store state (keep modal’s state in pinia), communicate through this.$root (available only in vue2).
2
Answers
Component communication plays major role in Frontend Famrworks like
Vue.js
.You can pass data from one component to another component at
same level
usingEvent bus
andstate management
(Majorly used Vuex).More details can be found here & here
As you mentioned, there are a bunch of different ways to achieve what you want:
However the most obvious and direct approach might be to communicate via parent component using props and emits: