let arr=res.data.data;
let newobj = {};
arr = arr .reduce((preVal, curVal) => {
newobj[curVal.fromUser] ? '' : newobj[curVal.fromUser] = preVal.push(curVal);
return preVal
}, [])
console.log('这是',arr);
let arr=res.data.data;
let newobj = {};
arr = arr .reduce((preVal, curVal) => {
newobj[curVal.fromUser] ? '' : newobj[curVal.fromUser] = preVal.push(curVal);
return preVal
}, [])
console.log('这是',arr);
本文标题:数组根据fromUser相同去重
本文链接:https://www.haomeiwen.com/subject/cnnkmktx.html
网友评论