I have two components: component A and component B. A.vue is like:
export default {
name: 'A',
data () {
var: true
}
}
B.vue is:
import A from './A'
export default {
name: 'B',
components: {
A
}
}
I want to use the dynamic value of variable var of component A in component B. I set a watcher therefore:
import A from './A'
export default {
name: 'B',
watch: {
A.data().var: func () {
console.log('Value of var changed in A.')
}
}
components: {
A
}
}
However, this approach does not work. Components A and B does not have the child-parent relationship, and therefore, I cannot use props. How can I do this?