【发布时间】:2020-09-23 05:41:51
【问题描述】:
我正在从服务器获取数据..
从服务器返回的数据是..
{
Increase: true,
Decrease: false,
Like:true,
Unlike: true,
Others: false,
Limits:true
}
以下是我在 Ngrx 服务调度后得到的结果
console.log('this.data=' +data);
this.data= [object Object]
现在做完 console.log('Object.keys(data)='+ Object.keys(data));
Object.keys(data)= Increase,Decrease,Like,Unlike,Others,Limits
如何在 console.log 之后获得如下相同的数据集
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
这样在 JSON.stringify 之后.. 我可以得到相同的数据,如下所示
[{"description":"Increase"},{"description":"Decrease"},{"description":"Like"},{"description":"Unlike"},{"description":"Others"},{"description":"Limits"},]
【问题讨论】:
-
我建议您开始使用逗号分隔console.log 中的元素:
console.log('this.data=', data);看到实际对象而不是[object Object] 更有用。 -
Object.entries()+Array.prototype.map()
标签: javascript jquery arrays json typescript