3👍
Your foreach was not an arrow function that’s why you can’t call this
inside of it. change all of your foreach to access this
inside of it.
this.myArray.forEach(item => {
// Here, you can use `this` already
});
1👍
Use arrow function to maintain your context.
this.myArray.forEach((item, index) => {
// Do here your stuff, without calling self, just "this"
});
Regards
- [Vuejs]-Vue and VueRouter creating separate instances of components
- [Vuejs]-How get array length for dynamic array
Source:stackexchange.com