原對(duì)象:
{
SF: '順豐速運(yùn)',
DBL: "德邦快遞"
}
轉(zhuǎn)換后:
[{
label: "順豐速運(yùn)"
value: "SF"
},{
label: "德邦快遞"
value: "DBL"
}]
源碼:
const obj = {
SF: '順豐速運(yùn)',
DBL: "德邦快遞"
}
const result = Object.keys(obj).map((el) => {
return {
value: el,
label: obj[el]
}
})
console.log(result)