[Vuejs]-VUEJS using "this" for component referencing

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

Leave a comment