How do I avoid needing to create a fake this in order to access the components data property? Because I have a new function that is passed to the Array.forEach the this keyword is in fact referring to the function rather than the Vue instance.
created () {
this.items.push({
value: 1000,
selected: false
});
var otherThis = this;
someAjaxOperation.returnedJson.forEach(function (item, index) {
otherThis.items.push({
selected: false,
value: item
})
});
}
As you can see, I have the hacky workaround of creating a copy of this. Is there a better way?