我有一个对象长得像这样:
const object = {
User 1 Fecha de Nacimiento: "02/05/2000",
User 1 Porcentage: 25,
User 1 Primer Apellido: "Gonzalez",
User 1 Segundo Apellido: "Perez",
User 1 Sexo: "H",
User 1 nombre: "Manuel",
User 2 Fecha de Nacimiento: "02/05/2000",
User 2 Porcentage: 25,
User 2 Primer Apellido: "Diaz",
User 2 Segundo Apellido: "Rodriguez",
User 2 Sexo: "M",
User 2 nombre: "Pepa",
}
我希望能够操作这个对象,使其根据每个用户的信息(即1或2)转换为一个类似于以下数组的基础形式:
const arrayOfObjects = [
{
Fecha de Nacimiento: "02/05/2000",
Porcentage: 25,
Primer Apellido: "Gonzalez",
Segundo Apellido: "Perez",
Sexo: "H",
Nombre: "Manuel"
},
{
Fecha de Nacimiento: "02/05/2000",
Porcentage: 25,
Primer Apellido: "Diaz",
Segundo Apellido: "Rodriguez",
Sexo: "M",
Nombre: "Pepa"
}
];
我需要一个帮助函数来完成这个任务,这样我就可以将其存储在React状态中(函数组件)。