对JSON对象按指定字段进行分组
groupBy(list, keyGetter) {
const map = new Map();
list.forEach((item) => {
const key = keyGetter(item);
const collection = map.get(key);
if (!collection) {
map.set(key, [item]);
} else {
collection.push(item);
}
});
return map;// 返回MAP
}
TS 加 … 把 MAP 转换成字典
const data = [...this.groupBy(rcs.RtnData, pet => pet.Goodssn)]
this.TongJiData = data;
```