let arr = [{
"code": "badge",
"priceList": [{
"amount": 3000
}]
},
{
"code": "DigitalPhoto",
"priceList": [{
"amount": 1990
}]
}
]
let arr2 = arr.reduce((pre,cur)=>{
pre[cur.code] = cur.priceList
return pre
},{})
console.log(arr2)
打印结果:
{ badge: [ { amount: 3000 } ],
DigitalPhoto: [ { amount: 1990 } ] }
原文地址:https://www.cnblogs.com/qiyc/p/9288512.html
时间: 2024-10-08 13:22:06