【发布时间】:2021-10-24 13:08:58
【问题描述】:
我有一个看起来像这样的对象:
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"
}
];
我需要一个辅助函数来执行此操作,因此我可以将其存储在反应状态(功能组件)中
【问题讨论】:
标签: javascript arrays reactjs object