数据如下,如何按照attributeValue这一项筛选,筛选出当前选中之前的attributeValue;
假设现在选取的是attributeValue3,应该如何筛选出3之前对应的值,感谢各位
let arr = [
{
"id": "d844c954-d6a9-4b2f-8b4e-0a0f32f7fabe",
"skuCode": "rwere",
"skuName": "4r3",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/5e8c6ec9-80f4-42cc-8364-76d89263d192.png",
"uniqueCategoryKey": "11,21,31",
"attributeName1": "高度",
"attributeValue1": "20",
"attributeName2": "花色",
"attributeValue2": "红",
"attributeName3": "高度",
"attributeValue3": "50cm"
},
{
"id": "706bbbe3-0880-40c3-b765-5aba54e15599",
"skuCode": "43432",
"skuName": "543543",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/159e2945-8df0-484f-9b03-d4b44e68eeb1.png",
"uniqueCategoryKey": "11,22,31",
"attributeName1": "高度",
"attributeValue1": "20",
"attributeName2": "花色",
"attributeValue2": "白",
"attributeName3": "高度",
"attributeValue3": "50cm"
},
{
"id": "be2ee289-6cc9-41a4-a7cf-3feb2e931810",
"skuCode": "432dd",
"skuName": "432",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/5e8c6ec9-80f4-42cc-8364-76d89263d192.png",
"uniqueCategoryKey": "12,21,31",
"attributeName1": "高度",
"attributeValue1": "50",
"attributeName2": "花色",
"attributeValue2": "红",
"attributeName3": "高度",
"attributeValue3": "50cm"
},
{
"id": "8c918746-448e-48af-ba11-4845032b437e",
"skuCode": "vfdfds",
"skuName": "sv",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/159e2945-8df0-484f-9b03-d4b44e68eeb1.png",
"uniqueCategoryKey": "12,22,31",
"attributeName1": "高度",
"attributeValue1": "50",
"attributeName2": "花色",
"attributeValue2": "白",
"attributeName3": "高度",
"attributeValue3": "50cm"
},
{
"id": "35dd54a9-03ed-4624-bdb4-d6b2ac4fbd5d",
"skuCode": "re",
"skuName": "wrewrew",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/5e8c6ec9-80f4-42cc-8364-76d89263d192.png",
"uniqueCategoryKey": "13,21,31",
"attributeName1": "高度",
"attributeValue1": "100",
"attributeName2": "花色",
"attributeValue2": "红",
"attributeName3": "高度",
"attributeValue3": "50cm"
},
{
"id": "fbbe454a-2177-449f-b320-df903e469e04",
"skuCode": "fds",
"skuName": "ds",
"price": "22.00",
"isShelf": "1",
"image": "https://lumall.inspures.com/images/product/159e2945-8df0-484f-9b03-d4b44e68eeb1.png",
"uniqueCategoryKey": "13,22,31",
"attributeName1": "高度",
"attributeValue1": "100",
"attributeName2": "花色",
"attributeValue2": "白",
"attributeName3": "高度",
"attributeValue3": "50cm"
}
]
如果是按某个属性值来过滤,推荐用lodash这个库来支持。
在Lodash中要过滤出所有
"attributeValue3": "50cm"
如下面处理: