我正在从后端获取一些项目,现在我想创建单独的重复数组 ItemsModels ,并希望将这些项目发布到后端...对此有任何帮助... >
从后端获取数据
const Items = [
{ uid: "01", item: "Car", carModel: "i 20", model: 2010 },
{ uid: "02", item: "Car", carModel: "i 10", model: 2009 },
{ uid: "03", item: "Car", carModel: "Swift", model: 2011 },
{ uid: "04", item: "Car", carModel: "Polo", model: 2015 }
];
我想要这样的重复数组。...
const ItemsModels = [
{ uid: "01", carModel: "Hundai i 20" },
{ uid: "02", carModel: "Hundai i 10" },
{ uid: "03", carModel: "Swift" },
{ uid: "04", carModel: "Polo" }
];
答案 0 :(得分:1)
您可以制作一张简单的地图
const ItemsModels = Items.map(item => {
const { uid, carModel } = item;
return { uid, carModel };
});