为了账号安全,请及时绑定邮箱和手机立即绑定

复杂结构的数组去重怎么操作

复杂结构的数组去重怎么操作

LEATH 2019-05-11 17:15:50
[[{"title":"11111111111","field":"","colspan":2,"rowspan":"1"},{"title":"11111111111","field":"","colspan":2,"rowspan":"1"},{"title":"22222222","field":"","colspan":"4","rowspan":"1"},{"title":"22222222","field":"","colspan":"4","rowspan":"1"},{"title":"22222222","field":"","colspan":"4","rowspan":"1"},{"title":"22222222","field":"","colspan":"4","rowspan":"1"}],[{"title":"3333333333","field":"","colspan":"2","rowspan":"1"},{"title":"3333333333","field":"","colspan":"2","rowspan":"1"},{"title":"4444444444","field":"","colspan":"3","rowspan":"1"},{"title":"4444444444","field":"","colspan":"3","rowspan":"1"},{"title":"4444444444","field":"","colspan":"3","rowspan":"1"},{"title":"单位数量2","field":"单位数量2","colspan":"1","rowspan":"3"}],[{"title":"中止1","field":"中止","colspan":"1","rowspan":"2"},{"title":"单位数量3","field":"单位数量3","colspan":"1","rowspan":"2"},{"title":"单位数量4","field":"单位数量4","colspan":"1","rowspan":"2"},{"title":"555555555","field":"","colspan":"2","rowspan":"1"},{"title":"555555555","field":"","colspan":"2","rowspan":"1"},{"title":"单位数量2","field":"单位数量2","colspan":"1","rowspan":"3"}],[{"title":"中止1","field":"中止","colspan":"1","rowspan":"2"},{"title":"单位数量3","field":"单位数量3","colspan":"1","rowspan":"2"},{"title":"单位数量4","field":"单位数量4","colspan":"1","rowspan":"2"},{"title":"单位数量5","field":"单位数量5","colspan":"1","rowspan":"1"},{"title":"单位数量6","field":"单位数量6","colspan":"1","rowspan":"1"},{"title":"单位数量2","field":"单位数量2","colspan":"1","rowspan":"3"}]]只保留第一次出现的后几次出现的删除结果要变成这样[[{"title":"11111111111","field":"","colspan":"3","rowspan":"1"},{"title":"22222222","field":"","colspan":"4","rowspan":"1"}],[{"title":"单位数量1","field":"单位数量1","colspan":"1","rowspan":"3"},{"title":"3333333333","field":"","colspan":"2","rowspan":"1"},{"title":"4444444444","field":"","colspan":"3","rowspan":"1"},{"title":"单位数量2","field":"单位数量2","colspan":"1","rowspan":"3"}],[{"title":"中止1","field":"中止","colspan":"1","rowspan":"2"},{"title":"单位数量3","field":"单位数量3","colspan":"1","rowspan":"2"},{"title":"单位数量4","field":"单位数量4","colspan":"1","rowspan":"2"},{"title":"555555555","field":"","colspan":"2","rowspan":"1"}],[{"title":"单位数量5","field":"单位数量5","colspan":"1","rowspan":"1"},{"title":"单位数量6","field":"单位数量6","colspan":"1","rowspan":"1"}]]
查看完整描述

2 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

arr.map(items=>{
varresult=[]
items.forEach(item=>{
if(!result.find(_item=>JSON.stringify(item)===JSON.stringify(_item))){
result.push(item)
}
})
returnresult
})
                            
查看完整回答
反对 回复 2019-05-11
  • 2 回答
  • 0 关注
  • 880 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信