【发布时间】:2021-04-12 05:06:22
【问题描述】:
我有一张数据表,其中显示了特定产品和全天购买的数量。它们作为不同的对象插入,我想添加每种产品购买的商品数量。
我的桌子是这样的
Apple 10 01/20/2021 18:30
Apple 5 01/29/2021 04:30
Apple 20 01/29/2021 07:30
但我希望它们组合成like
Apple 35
到目前为止,这就是我设置表格的方式
<Table striped="true" size="sm" style={{width: "20%"}}>
<tbody>
{this.state.products?.map((product, index) => (
<tr key={`entity-${index}`}>
<td>{product.type}</td>
<td>{product.amount}</td>
</tr>
))}
</tbody>
</Table>
如何根据类型组合这些数据?
【问题讨论】:
标签: javascript arrays object filter combinations