【发布时间】:2021-10-06 15:57:19
【问题描述】:
我正在尝试将我的数据与键组合,但情况很奇怪。
数据:1
"qrCode": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
"gallery": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
"Whatsapp": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
//continues like this.
数据:2
[
TextRow { score: '1', date: '2021-10-09', value: '', label: 'share' },
TextRow {
score: '5',
date: '2021-10-06',
value: '',
label: 'qrCode'
},
TextRow {
score: '1',
date: '2021-10-06',
value: '',
label: 'gallery'
},
TextRow {
score: '1',
date: '2021-10-06',
value: 'https://api.whatsapp.com/send?phone=+905448514495',
label: 'Whatsapp'
},
TextRow {
score: '1',
date: '2021-10-06',
value: 'https://twitter.com/90pixel',
label: 'Twitter'
},
TextRow {
score: '2',
date: '2021-10-06',
value: 'https://trendyol.com/jump/yeni-sezon-outdoor-erkek-spor-ayakkabi-25715-navy-p-57375516?boutiqueId=556044&merchantId=655',
label: 'Trendyol'
},
TextRow {
score: '1',
date: '2021-10-08',
value: 'https://goo.gl/maps/z3RRpzp5SgxToDv18',
label: 'Lokasyon'
}
]
我想将它们与单个函数组合,但输出错误。我在结果上得到的每个元素都是一样的。
},
"qrCode": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
"gallery": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
"Whatsapp": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
"Twitter": {
"2021-10-03": 0,
"2021-10-04": 0,
"2021-10-05": 0,
"2021-10-06": "2",
"2021-10-07": 0,
"2021-10-08": "1",
"2021-10-09": "1"
},
我有点不知道那里出了什么问题。这是我的功能。它保留每个键并添加连续键。我该怎么办?
data2.forEach((statistic) => {
data1[statistic.label][statistic.date] = Number(statistic.score);
});
【问题讨论】:
标签: arrays array-merge