// 假设有一个对象
const myObject = {
key1: 'value1',
key2: 'value2',
key3: 'value3'
};
// 将键值对转换为具有 { label, value } 结构的列表
const myList = Object.entries(myObject).map(([label, value]) => ({ label, value }));
console.log(myList);
如果转为id,name结构的list
// 将键值对转换为具有 { id, name } 结构的列表
const myList = Object.entries(myObject).map(([id, name]) => ({ id, name }));