Answer the question
In order to leave comments, you need to log in
How to pass a variable to another vue component?
Good afternoon, there is such a question, how to transfer the value of a variable from one component to another neighboring one? The difficulty is that this should happen on click. I have a button in one component that opens the menu, the second component is the menu itself. I read about props, but he also receives a variable from the very beginning, and it becomes undefined.
Panel with button:
export default{
name: "left-aside",
isBarMenuClicked: false, // эту переменную нужно передать
methods: {
openLeftMenu: function(){
this.isBarMenuClicked = true;
}
}
}
export default {
name: "boards-menu",
data() {
return {
isLeftMenuShowed: true, // вторая переменная, отвечающая за меню
}
},
methods: {
closeLeftMenu: function () {
this.isLeftMenuShowed = false
}
},
props: [
'isBarMenuClicked'
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question