let list = {
'1': {
"text": "SERE"
},
'2': {
"text": "MM"
},
'3': {
"text": "Production"
},
};
或
let list = [
{
"text": "SERE"
},
{
"text": "MM"
},
{
"text": "Production"
},
];
let newList = [];
for (let [key, value] of Object.entries(list)) {
newList.push({
key: key,
label: value.text
})
}
console.log(newList)
//结果 [
{
"key": "0",
"label": "SERE"
},
{
"key": "1",
"label": "MM"
},
{
"key": "2",
"label": "Production"
}
]