Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在阵列中放置道具_Reactjs_Maven_Jhipster - Fatal编程技术网

Reactjs 如何在阵列中放置道具

Reactjs 如何在阵列中放置道具,reactjs,maven,jhipster,Reactjs,Maven,Jhipster,我对这个代码有一个问题。这是一个用jHipser生成的项目,这是一个我不熟悉的东西 所以我使用的是 数据必须采用此格式 const数据={ 栏目:[ {...} ], 行:[ {...} ] }; 我的数据是通过props收集的,并像这样存储 const{bookList,match}=this.props 列是固定的,并且按其应该的方式填充。我需要用存储在图书列表中的数据填充行。有什么办法吗 我还没反应过来,所以对我放轻松:) 编辑 下面是一个bookList的示例 0: id: 1

我对这个代码有一个问题。这是一个用jHipser生成的项目,这是一个我不熟悉的东西

所以我使用的是

数据
必须采用此格式

const数据={
栏目:[
{...}
],
行:[
{...}
]
};
我的数据是通过
props
收集的,并像这样存储

const{bookList,match}=this.props

是固定的,并且按其应该的方式填充。我需要用存储在
图书列表
中的数据填充
。有什么办法吗

我还没反应过来,所以对我放轻松:)

编辑

下面是一个bookList的示例

0:
  id: 1
  records: null
  serialNumber: "enable Gorgeous Frozen Pants"
  yearRange:
    createdAt: "2019-11-04T13:28:16Z"
    firstYear: 37454
    id: 1
    lastYear: 79654
    updatedAt: "2019-11-05T07:53:08Z"
我有更多的。通过尝试这个,我更接近解决方案

rows: [
        {
          id: `${bookList.map(result => result.id)}`,
        }
      ]

但它将
bookList
中的所有ID放入这个
ID
中,并将它们显示在表中的一行中。我需要创建尽可能多的行,因为bookList中有元素。

列是json数组,其中包含键字段和标签

现在,您的行应该有数据,其中键作为列中的字段值

例如,如果

columns: [
  {
    label: 'Name',
    field: 'name'
  },
  {
    label: 'Position',
    field: 'position'
  }]
那么行应该是这样的

rows: [
  {
    name: 'Tiger Nixon',
    position: 'System Architect'
  },
  {
    name: 'Garrett Winters',
    position: 'Accountant'
  }]

尝试以这种方式更改您的图书列表。

将值映射到
数组中,而不是映射到
id
键中

const数据={
列:[{…}],
行:bookList.map(book=>(
{id:book.id,…在此处添加所需的所有密钥…}
) 
}