if the id of two arrays is equal, I will change the activeName field in the first array to true,. I use this to determine whether he is added to the collection or not. If true is added, false is not added. I added the fields that the background did not return to me with such a status. So the list array that needs to be collected should be compared with my current two. Id, if id is equal, it means that one record is in a collection state, that is, it is rewritten to true.
. How do these two arrays determine that when major_id equals id, make the activeName field true:
_this.listWish.forEach(function(a) {
_this.major.forEach(function(item) {
if (item.major_id == a.id) {
_this.$set(a, "activeName", true);
_this.$set(a, "wishId", item.wish_id);
} else {
_this.$set(a, "activeName", false);
}
});
});
-sharp-sharp
but after I loop like this, the value of the activeName field is not rewritten correctly, it"s all false.