- 格式如下
- resData=[{device_id: 290, handled_by: '', org: '1号分公司', description: '' "}, {device_id: 290, handled_by: '', org: '1号分公司', description: '' "}, {device_id: 230, handled_by: '', org: '2号分公司', description: '' "}, {device_id: 240, handled_by: '', org: '3号分公司', description: '' "}, {device_id: 250, handled_by: '', org: '4号分公司', description: '' "}, {device_id: 290, handled_by: '', org: '1号分公司', description: '' "}, {device_id: 290, handled_by: '', org: '1号分公司', description: '' "}]
去重处理
let resobj={};
resData = resData.reduce((item,next) => {
resobj[next.device_id] ? '' : resobj[next.device_id] = true && item.push(next);
return item;
},[]);
console.log(resData)
控制台打印:
[{device_id: 290, handled_by: '', org: '1号分公司', description: '' "}, {device_id: 230, handled_by: '', org: '2号分公司', description: '' "}, {device_id: 240, handled_by: '', org: '3号分公司', description: '' "}, {device_id: 250, handled_by: '', org: '4号分公司', description: '' "},]