the code is as follows:
import headerVue from "./components/header.vue";
import bodyVue from "./components/body.vue";
import footerVue from "./components/footer.vue";
import connector from "./components/connector.js";
export default {
data: function() {
return {
textInfo: "This is Father Div",
listenText: ["a","B"]
};
},
methods: {
listen: function() {
connector.$on("phone", function(msg) {
// this.listenText.push(msg);
console.log(app.listenText); // this.listenTextundefined
// console.log(msg);
});
}
},
props: [],
components: {
headerVue: headerVue,
bodyVue: bodyVue,
footerVue: footerVue
}
};
in the above code, when using the parent component to listen for the value passed by the child component, after the child component passes the value, the parent component"s $on event is triggered, and it is possible to output msg directly, but the variables defined in data cannot be accessed here. What"s going on?