繁体   English   中英

垂直显示的React-Table列标题

[英]React-Table Column Headers Displaying Vertically

我正在使用React-Table模块创建一个表。 到目前为止,我有以下内容:

<div>
    <ReactTable
    columns={[{columns :
        [{
          Header: "Time",
          accessor: "time", //name of field in table
        },
        {
          Header: "Weight",
          accessor: "weight",
        }
      ]}]}
    />
</div>

但是,我的列标题是这样垂直显示的:

时间

重量

我希望它们按预期水平显示。

根据文档,每个列标题都是一个对象数组,因此传递给它的每个对象都有一个水平显示的标题。 在您的示例中,您仅传递了支持一个对象的列,请尝试使其更像文档示例中所示:

 const columns = [{
        Header: 'Name',
        accessor: 'name' // String-based value accessors!
      }, {
        Header: 'Age',
        accessor: 'age',
        Cell: props => <span className='number'>{props.value}</span> // Custom cell components!
      }, {
        id: 'friendName', // Required because our accessor is not a string
        Header: 'Friend Name',
        accessor: d => d.friend.name // Custom value accessors!
      }, {
        Header: props => <span>Friend Age</span>, // Custom header components!
        a

ccessor: 'friend.age'
  }]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM