var list = [
{ id: '1', name: 'test1', rName: 'the1' },
{ id: '1', name: 'test1', rName: 'the2' },
{ id: '1', name: 'test1', rName: 'the3' },
{ id: '2', name: 'test2', rName: 'the1' },
{ id: '2', name: 'test2', rName: 'the2' },
{ id: '3', name: 'test3', rName: 'the1' },
{ id: '4', name: 'test3', rName: 'the1' },
{ id: '5', name: 'test3', rName: 'the1' },
]
var list2 = []
for (var i in list) {
var list3 = []
for (var j in list) {
if (list[i].id == list[j].id && list[j].key != 1) {
list[j].key = 1
list3.push(list[j])
}
}
if (list3.length > 0) {
list2.push(list3)
}
}
console.log('2222', list2)
发表回复