[Vuejs]-How to set/get data from other imported components?

0👍

Communication between components is mainly achieved via props and events. If component relationship is parent-child, from your parent component, you can use props to provide data to child and use events to receive data from child.

If components are siblings, you can achieve their communication through parent. For example, If A is parent of B & C [that makes B & C siblings] and you want to send some data from B to C, then you will raise an event from B, listen it in A, update local variables and send those as props in C.

For more complex scenarios of data sharing, you will have to use state management techniques like redux or vuex.

Leave a comment