data() {
return {
cr: "", // Current route
isAdmin: false
};
},
created() {
this.cr = this.$router.currentRoute.name;
console.log(this.isAdmin); // false
EventBus.$on("logged", function() {
console.log(this.isAdmin); // undefined
console.log("isAdmin true!"); // logs just fine!
});
}
This is part of a Vue app where I use an 'Event Bus' as outlined here.
As shown in the inline comments in this code, inside created()
, I get a value for this.isAdmin
. However, inside of the Event Bus callback, that same value is undefined
❓