I have data that I need to pass from one component1 to another component2.
I don't use vuex or router.
Components tree:
-Parent
--Component1
--Component2
From first component1 I make ajax request, retrieving info and pushing to data.
board: [1,2,3,4,5]
And I need access that retrieved data in component2
Can I do It without vuex or router ?
Thank you :)
You could emit an event to parent from component1 having as parameters the updated board and in the parent one receive that and pass it through props to component2
In component1 :
this.$emit("sendToComp2",this.board);
in the parent component :
<template>
<component1 @sendToComp2="sendTo2"/>
...
<component2 :boards="boards" />
....
</template>
data:{
boards:[]
},
methods:{
sendTo2(boards){
this.boards=boards
}
}
component2 should have property called boards
props:["boards"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With