我在单独的文件中将以下数据作为对象数组
export const usersRowData = [
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"value": "Leanne Graham",
"label": "Leanne Graham"
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna@melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
}
}
]
在我的React组件内部,我将这些过滤器数据用于下拉列表硬编码为值和标签:
const filters = [
{
label: "name",
options: [
{ value: "Dietrich", label: "Dietrich" },
{ value: "Patricia", label: "Patricia" }
]
},
{
label: "username",
options: [
{ value: "Kamren", label: "Kamren" },
{ value: "Bret", label: "Bret" }
]
},
{
label: "email",
options: [{ value: "Sincere@april.biz", label: "Sincere@april.biz" }]
}
];
我如何循环数组将每个名称输出为我的react组件内的值和标签,以便可以在列表中显示它们。
PIPIONE
慕姐8265434
相关分类