//定义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 }));
11-30
6620
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-07
260
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交