我将如何在嵌套项目上使用 filter() ?我正在尝试检索具有 projex.HeightPay === '1' 的所有数据。如果 HeightPay 为 1,我想取回 Id、Name、System 等和项目项目。
例如:
const fakeData = [
{
Id: "022173333101",
Name: "Blue",
System: "DESIGN",
Squares: 0,
Attributes: {
projex: [
{
Project: "50",
HeightPay: "1"
},
{
Project: "50",
HeightPay: "0"
}
]
},
Customer: {
Addr1: "Somewhere",
Addr2: ""
}
}
];
// returns nothing
const found = fakeData.filter(data => data.Attributes.projex.HeightPay === "1");
期望的输出:
{
Id: "022173333101",
Name: "Blue",
System: "DESIGN",
Squares: 0,
Attributes: {
projex: [
{
Project: "50",
HeightPay: "1"
}
]
},
Customer: {
Addr1: "Somewhere",
Addr2: ""
}
}
交互式爱情
鸿蒙传说
相关分类