【发布时间】:2019-05-12 10:03:49
【问题描述】:
我的数组如下所示:
Array [
Object {
"color": "Brown",
"time": "18:32",
},
Object {
"color": "Red",
"time": "18:33",
},
]
但是如何将 Object 更改为名称?
我是这样推的
const itemLogs = [];
childSnapshot.forEach((csh) => {
let childKeys = csh.key;
itemLogs.push({
color: csh.val().color,
time: csh.val().time
});
});
this.setState({childData: itemLogs});
更新:
这就是我想要的方式:
10-05-2019 [
14:27 {
"color": "Brown",
"time": "14:27",
},
14:23 {
"color": "Red",
"time": "14:23",
},
],
11-06-2019 [
like above but other data
]
我希望这是一个更好的例子。
【问题讨论】:
标签: arrays reactjs react-native object arraylist