I have two modules: module X
and module Y
. X.js
is structured as follows:
export default {
name: 'X',
data () {
var: true
}
}
The structure of Y.js
is as follows:
import X from './X'
export default {
name: 'Y',
components: {
X
}
}
I aim to access the dynamically changing value of variable var
from module X
in module Y
. To achieve this, I implemented a watcher:
import X from './X'
export default {
name: 'Y',
watch: {
X.data().var: function() {
console.log('Value of var changed in X.')
}
},
components: {
X
}
}
Despite the mentioned method not yielding the desired outcome. Modules X
and Y
lack a parent-child relationship, thereby restricting the use of props. How can I address this issue?