【发布时间】:2023-03-31 03:49:01
【问题描述】:
这是我的数组,dataCom
id: "5c9e3f0aa289e606b46a7fdf"
importPrices: 500
name: "Wings spring"
owner: "5c40442b6e4425163915e5b3"
priceBaseOnBOM: 0
productId: "LXCM"
salePrices: 0
我想像这样将一些属性传递给新数组(组件)
components.push({
salePrices: dataCom.salePrices,
productId:dataCom.productId,
name: dataCom.name,
amount: dataCom.amount,
id: dataCom.id})
但这是不对的。我想要这样的组件
components
[
id: "5c9e3f0aa289e606b46a7fdf",
name: "Wings spring",
productId: "LXCM"
salePrices: 0
]
请帮忙,非常感谢
【问题讨论】:
-
你想要的输出是一个数组,它包含键,否则不可能用对象数组或单个对象数组替换它
标签: javascript arrays object ecmascript-6