我的原始数据如下所示:
Array [
Array [
Object {
"Date": "Sun Mar 24 14:08:34 2021",
"customer_name": "Test name 1",
"customer_paid": 66,
},
],
Array [
Object {
"Date": "Sun Mar 21 14:08:34 2021",
"customer_name": "Test name 2",
"customer_paid": 46,
},
],
]
我试着让它看起来像这样:
CvertData ={{
'Sun Mar 21 14:08:34 2021': [{Client: 'Test name 1' , amount : 66}],
'Sun Mar 21 14:08:34 2021': [{Client: 'Test name 2', amount: 46}]
}}
我确实使用了这段代码,但我不知道问题出在哪里:
const items = [];
for (let element of OriginalData) {
var Elmdate= element['Date']
items[Elmdate].push({
Client: element['customer_name'],
amount: element['customer_paid']
});
}