需求:有一个数组,需要找出比旧数组多的数据,删除的数据
getNewValues(arr1, arr2) {
let res = [];
arr2.forEach((item, idx) => {
if (arr1.indexOf(item) == -1) res.push(item);
});
return res;
},
调用
// 新增的列表
let arr1 = _this.getNewValues(_this.oldList, arr);
// 删除的列表
let arr2 = _this.getNewValues(arr, _this.oldList);