I am currently working with a variable in my data:
data: function () {
return {
myVariable: false,
}
}
I'm trying to figure out how to access this variable within a looping function, like the example below:
anArray.forEach(function(item) {
this.myVariable = true;
// do something
});
I keep encountering the error 'this' is undefined because it's referencing the current loop function, not the Vue.js object.