transferData: Array<any> = []; //全部
targetKeys: Array<any> = []; //选中的
certainPersonnel: Array<any> = [];//点击确认后选择的数据
let newArr: any = [];
this.targetKeys.forEach((item: any) => {
this.transferData.forEach((items: any) => {
if (item === items.value) {
newArr.push(items);
}
});
});
//数组去重
let temp: any = {};
this.certainPersonnel = newArr.reduce((prev: any, curv: any) => {
if (temp[curv.key]) {
} else {
temp[curv.key] = true;
prev.push(curv);
}
return prev;
}, []);
js数组去重
最新推荐文章于 2022-12-20 20:26:28 发布