2 回答
TA贡献1833条经验 获得超4个赞
我的想法是处理数据
let articleList=[
{id:1,name:"小红",user:456312,Occupation:"教练"},
{id:2,name:"小张",user:456321,Occupation:"歌手"},
{id:5,name:"小强",user:456312,Occupation:"老师"},
{id:2,name:"小分",user:456312,Occupation:"同事"},
{id:5,name:"小撒",user:456132,Occupation:"总经理"},
{id:2,name:"小看",user:456132,Occupation:"程序猿"},
{id:5,name:"小贫",user:451632,Occupation:"演员"}
];
let idArr=articleList.map(function(x){return x.id})
![图片描述][1]
//得到id的集合
//去重
idArr=Array.from(new Set(idArr));
//遍历此数组并在articleList找到id相同的放入新数组
let newArr=[];
idArr.forEach(function(v){
newArr.push(articleList.filter(function(x){
return x.id==v
}))
})
//得到newArr
![图片描述][2]
渲染便利此数组即可
添加回答
举报