原对象:
{
SF: '顺丰速运',
DBL: "德邦快递"
}
转换后:
[{
label: "顺丰速运"
value: "SF"
},{
label: "德邦快递"
value: "DBL"
}]
源码:
const obj = {
SF: '顺丰速运',
DBL: "德邦快递"
}
const result = Object.keys(obj).map((el) => {
return {
value: el,
label: obj[el]
}
})
console.log(result)