繁体   English   中英

React Table默认分页页面

[英]React Table default pagination page

我是表的新手。 是否可以在分页模式下设置默认页面。 是否有某种道具可以解决这个问题? F.ex. 装入组件后,我想在第5页上打开表格。 谢谢!

您可能已经发现了这一点,但是为了扩展hariharan的答案,您可以使用组件的状态来控制表的许多道具。 对于页面,您可以告诉组件该页面处于状态,

<ReactTable
    ...otherProps
    page={this.state.page}
  />

而且,无论您如何初始化状态,都必须将其页面等于5。例如,

class MyClassThatHasReactTableInIt extends Component {
  constructor (props) {
    super(props);
    this.state = {
      page: 5
  }
... // etc code etc

如果这样做,您还需要处理更改自己的页面。 幸运的是 ,react-table使这非常容易,您可以编写自定义的pageChange处理程序:

    <ReactTable
    ...otherProps
    page={this.state.page}
    onPageChange={page => this.setState({page})}
  />

只需在<ReactTable />组件中添加page <ReactTable />

  <ReactTable
    ...otherProps
    page={5}
  />

只需将5更改为所需的页码即可。

暂无
暂无

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

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