theNowDetailList amount 4 failReason null inventory 2014T4铝板 latestPrice 18000 productBatchId null productName 2014T4 property 单面微粘蓝膜喷码
您可以使用forEach循环遍历theNowDetailList数组,然后在每个对象的productList中添加一个新的对象。可以使用Object.assign方法将外层对象的内容复制到新的对象中,并增加所需的属性。
以下是一个示例代码:
theNowDetailList.forEach(function(detail) {
var newProduct = Object.assign({}, detail, {
theNowDetailId: detail.theNowDetailId,
theNowId: detail.theNowId,
productId: null,
isEdit: true,
classeIds: [],
classes: "",
variety: detail.variety,
productName: detail.productName,
specification: detail.specification,
property: detail.property,
weight: detail.weight,
surface: detail.surface,
tectorial: detail.tectorial,
priceUnit: "元/kg",
amountUnit: "kg"
});
detail.productList.push(newProduct);
});
这样,theNowDetailList数组中的每个对象的productList中都会添加一个新的对象,该对象包含外层对象的内容,并添加了额外的属性
原文地址: http://www.cveoy.top/t/topic/iGgO 著作权归作者所有。请勿转载和采集!