Javascript 从React Js中的数组列表获取输入字段

Javascript 从React Js中的数组列表获取输入字段,javascript,Javascript,我已经从API获取了数组,其中提到了输入字段,下面是示例: customerAttribute: Array(11) 0: {attributeId: 1, attributeName: "FirstName", attributeType: "String", isMandatory: false} 1: {attributeId: 2, attributeName: "LastName", attributeType: "String", isMandatory: false} 2: {at

我已经从API获取了数组,其中提到了输入字段,下面是示例:

customerAttribute: Array(11)
0: {attributeId: 1, attributeName: "FirstName", attributeType: "String", isMandatory: false}
1: {attributeId: 2, attributeName: "LastName", attributeType: "String", isMandatory: false}
2: {attributeId: 3, attributeName: "DateOfBirth", attributeType: "Date", isMandatory: false}
3: {attributeId: 4, attributeName: "Email Address", attributeType: "String", isMandatory: false}
4: {attributeId: 5, attributeName: "Mobile Number", attributeType: "Number", isMandatory: false}
5: {attributeId: 6, attributeName: "Address Line 1", attributeType: "String", isMandatory: false}
6: {attributeId: 7, attributeName: "Address Line 2", attributeType: "String", isMandatory: false}
7: {attributeId: 8, attributeName: "City", attributeType: "String", isMandatory: false}
现在,我已经在其中提到了默认字段:

 const ABC = [
    { ...firstName, order: 1 },
    { ...lastName, order: 2 },
    { ...mobileNumber, order: 3 },
    { ...email, order: 4 },
    { ...address1, order: 5 },
    { ...address2, order: 6 },
    { ...city, order: 7 },
 ]
我只想显示CustomerAttribute数组列表中可用的字段


有人能建议我该怎么做吗?。

首先,响应始终是JSON格式的,它将在数组中,它必须是这样的,下面是for循环,它将为您提供所需的值,如attributeID、attributeName

var  customerAttribute =
[ {attributeId: 1, attributeName: "FirstName", attributeType: "String", isMandatory: false},
 {attributeId: 2, attributeName: "LastName", attributeType: "String", isMandatory: false},
 {attributeId: 3, attributeName: "DateOfBirth", attributeType: "Date", isMandatory: false},
 {attributeId: 4, attributeName: "Email Address", attributeType: "String", isMandatory: false},
 {attributeId: 5, attributeName: "Mobile Number", attributeType: "Number", isMandatory: false},
 {attributeId: 6, attributeName: "Address Line 1", attributeType: "String", isMandatory: false},
 {attributeId: 7, attributeName: "Address Line 2", attributeType: "String", isMandatory: false},
 {attributeId: 8, attributeName: "City", attributeType: "String", isMandatory: false}]


    for (let index = 0; index < customerAttribute.length; index++) {

        console.log(customerAttribute[index].attributeId)
        console.log(customerAttribute[index].attributeName)

    }
var客户属性=
[{attributeId:1,attributeName:“FirstName”,attributeType:“String”,isMandatory:false},
{attributeId:2,attributeName:“LastName”,attributeType:“String”,isMandatory:false},
{attributeId:3,attributeName:“出生日期”,attributeType:“日期”,isMandatory:false},
{attributeId:4,attributeName:“电子邮件地址”,attributeType:“字符串”,isMandatory:false},
{attributeId:5,attributeName:“手机号码”,attributeType:“号码”,isMandatory:false},
{attributeId:6,attributeName:“地址行1”,attributeType:“字符串”,isMandatory:false},
{attributeId:7,attributeName:“地址行2”,attributeType:“字符串”,isMandatory:false},
{attributeId:8,attributeName:“城市”,attributeType:“字符串”,isMandatory:false}]
for(让index=0;index
以上是API的响应?customerAttributes是API的响应。它必须在数组中!!!像customer customerAttribute:[{attributeId:1,attributeName:“FirstName”,attributeType:“String”,isMandatory:false}]是的。。我已经从控制台日志粘贴了响应,这是JSON,我需要它在React Js中