this.atsListProcessCustomDetail(params).then((res) => {
// res.data 从后端取得的数组
if (res.bizCode == 0) {
let dataArr = res.data
var arrs = []
if(dataArr.length>1){
dataArr[0].customDetails.forEach(e => {
var compare = e.name;
var num = 0
for (let i = 1; i < dataArr.length; i++) {
//compare 数组里的名字判重
if(JSON.stringify(dataArr[i].customDetails).indexOf(compare) > -1){
num+=1
}
if(i == dataArr.length-1){ //循环到最后一次
//alert(num)
if(num == i){
arrs.push(e)
}
}
}
});
//console.log("合并完的数据为="+JSON.stringify(arrs))
}else{
arrs = dataArr[0].customDetails
}
console.log('合并的数组为='+JSON.stringify(arrs))
this.liuAllArr = arrs;
}
});
js 数组对象取交集
最新推荐文章于 2024-06-14 17:08:32 发布