取出id
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
var arr = [
{
"spe_id": "121213202704519463156432559404870139904",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "白色"
},
{
"skuLabel": "尺码",
"value": "S"
}
],
"prod_sku_sale_price": "111.000000",
"prod_sku_stock": 111
},
{
"spe_id": "121213202704519535576842559404886917120",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "白色"
},
{
"skuLabel": "尺码",
"value": "L"
}
],
"prod_sku_sale_price": "212.000000",
"prod_sku_stock": 121
},
{
"spe_id": "121213202704519585198402559404886917120",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "白色"
},
{
"skuLabel": "尺码",
"value": "M"
}
],
"prod_sku_sale_price": "2222.000000",
"prod_sku_stock": 222
},
{
"spe_id": "121213202704519646744892559404903694336",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "黑色"
},
{
"skuLabel": "尺码",
"value": "M"
}
],
"prod_sku_sale_price": "9999.999999",
"prod_sku_stock": 3213
},
{
"spe_id": "121213202704519696303532559404903694336",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "黑色"
},
{
"skuLabel": "尺码",
"value": "S"
}
],
"prod_sku_sale_price": "123.000000",
"prod_sku_stock": 31231
},
{
"spe_id": "121213202704519739127742559404920471552",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "白色"
},
{
"skuLabel": "尺码",
"value": "XL"
}
],
"prod_sku_sale_price": "121.000000",
"prod_sku_stock": 121
},
{
"spe_id": "121213202704519768717942559404920471552",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "黑色"
},
{
"skuLabel": "尺码",
"value": "L"
}
],
"prod_sku_sale_price": "3123.000000",
"prod_sku_stock": 3213
},
{
"spe_id": "121213202704519788309642559404920471552",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "红色"
},
{
"skuLabel": "尺码",
"value": "M"
}
],
"prod_sku_sale_price": "9999.999999",
"prod_sku_stock": 3123
},
{
"spe_id": "121213202704519883100782559404937248768",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "黑色"
},
{
"skuLabel": "尺码",
"value": "XL"
}
],
"prod_sku_sale_price": "312.000000",
"prod_sku_stock": 312
},
{
"spe_id": "121213202704519910950992559404954025984",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "红色"
},
{
"skuLabel": "尺码",
"value": "L"
}
],
"prod_sku_sale_price": "3123.000000",
"prod_sku_stock": 3123
},
{
"spe_id": "121213202704519921688162559404954025984",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "红色"
},
{
"skuLabel": "尺码",
"value": "S"
}
],
"prod_sku_sale_price": "3242.000000",
"prod_sku_stock": 3123
},
{
"spe_id": "121213202704520025540792559404970803200",
"prod_specs": [
{
"skuLabel": "颜色",
"value": "红色"
},
{
"skuLabel": "尺码",
"value": "XL"
}
],
"prod_sku_sale_price": "3213.000000",
"prod_sku_stock": 31233
}
]
var arr1 = {
sku0: "黑色",
sku1: "M"
}
arr.forEach(item => {
item.prod_specs.forEach(v => {
if (v.skuLabel == "颜色") {
if (v.value == arr1.sku0) {
let arr2 = item.prod_specs
arr2.forEach(s=>{
if (s.skuLabel == "尺码") {
if (s.value == arr1.sku1) {
console.log(item)
}
}
})
}
}
})
})
</script>
</html>