Answer the question
In order to leave comments, you need to log in
How to interact with the state of one component in another?
Hello everyone
I've been working with VueJs for a while now, but recently I got a project that I would like to understand.
There are two components:
Header.vue
Menu.vue The Menu.vue
component has a button "close right menu" , when clicked, the right menu disappears:
<button @click="menuShow = false">close</button>
data() {
return {
menuShow: true,
};
},
Answer the question
In order to leave comments, you need to log in
For the overall state of the entire application: vuex .
To link children who cannot live without a particular parent to that parent: provide \ inject .
For a tight bunch of single components: a separate Vue.observable \ Vue.reactive object imported in the required components.
For explicit interaction of nearby components, the usual vue-flow: up events through $emit and @on, down props.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question