let key = {}; //存储的 key 是type的值,value是在indeces中对应数组的下标 let indices = [] //数组中每一个值是一个数组,数组中的每一个元素是原数组中相同type的下标 newData.map((item, index) => { let type= item.requirementId//list实体去重字段 let _index = key[type] if (_index !== undefined) { indices[_index].push(index) } else { key[type] = indices.length indices.push([index]) } }) // 归类结果 let result = [] indices.map((item) => { item.map((index) => { //result.push(List[index]) 相同项排序在一起 //if (item.length > 1) {} 只要重复项 //if (item.length == 1){} 只要单独项 //这里需要重复项 if (item.length > 1) { result.push(newData[index]) } }) })