//定义Map
moreInfoList = new Map();
moreInfoArray = [{ key: '', value: [] }];
//jsonData是json类型的数据,下面代码中的this.beInfo是项目中api返回的内容
const jsonData = this.beInfo;
const infoMap = new Map();
for (const key in jsonData) {
if (jsonData.hasOwnProperty(key)) {
infoMap.set(key, jsonData[key]);
}
}
// filter the info whose properties is not null
infoMap.forEach((value, key) => {
if (MORE_INFO.includes(key) && value.properties.length > 0) {
// put the result in a new Map
this.moreInfoList.set(key, value.properties);
}
});
// change to array
this.moreInfoArray = Array.from(this.moreInfoList.entries()).map(([key, value]) => ({ key, value }));
08-10
1万+
