Reactjs 如何在react中获取当前页码onPagechange函数
我试图在react表中单击next获取当前页码,但看不到当前页码Reactjs 如何在react中获取当前页码onPagechange函数,reactjs,react-table,Reactjs,React Table,我试图在react表中单击next获取当前页码,但看不到当前页码 <div className="article_full"> <h2>DETAILS</h2> <ReactTable filterable columns= . {this.getTableColumns()} data={items} pagination={true} onChange={this.onPageChange}/> </div> onPageCha
<div className="article_full">
<h2>DETAILS</h2>
<ReactTable filterable columns= .
{this.getTableColumns()} data={items} pagination={true} onChange={this.onPageChange}/>
</div>
onPageChange(pagination, filters, sorter) {
//projectId = this.props.match.params;
alert(pagination.current)
}
细节
onPageChange(分页、过滤器、分拣机){
//projectId=this.props.match.params;
警报(分页。当前)
}
您正在对ReactTable组件调用错误的受控状态回调。尝试调用onPageChange
,而不是onChange
:
<div className="article_full">
<h2>DETAILS</h2>
<ReactTable
filterable
columns={this.getTableColumns()}
data={items}
pagination={true}
onPageChange={this.onPageChange}/>
</div>
onPageChange(pageIndex) {
alert(pageIndex);
}
您使用的是哪一版本的react表格?v5、v6或v7?谢谢!!。只有分页才能工作,而不是警报(pagination.current)。警报(pagination.current)给出的是未定义的。我的错,您只能作为
pageIndex
访问第一个参数。将相应更新
// Callbacks
onPageChange={(pageIndex) => {...}} // Called when the page index is changed by the user
onPageSizeChange={(pageSize, pageIndex) => {...}} // Called when the pageSize is changed by the user. The resolve page is also sent to maintain approximate position in the data
onSortedChange={(newSorted, column, shiftKey) => {...}} // Called when a sortable column header is clicked with the column itself and if the shiftkey was held. If the column is a pivoted column, `column` will be an array of columns
onExpandedChange={(newExpanded, index, event) => {...}} // Called when an expander is clicked. Use this to manage `expanded`
onFilteredChange={(filtered, column) => {...}} // Called when a user enters a value into a filter input field or the value passed to the onFiltersChange handler by the Filter option.
onResizedChange={(newResized, event) => {...}} // Called when a user clicks on a resizing component (the right edge of a column header)