Using forEach method in Vue
Posted on: March 02, 2021 by Prince Chukwudire
In this article, you will learn how to use the forEach method in vue.
In general, the forEach
method runs a provided method once for each element in the array.
A simple forEach method in vue can be done in vue like so:
let newData = [];
this.data.forEach((value,index ) => {
newData.push(value);
console.log("newData", newData);
});
Here data
is a property in our instance. This can also be done directly with payload data gotten from an API call.
Share on social media
//