亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - react routing issues about antd multi-page pagination
PHPz
PHPz 2017-05-19 10:16:55
0
2
1189

Use antd's table to develop a simple multi-page page. Multi-page pagination is included in the table. This is my first time using react@15.5.4, react-router@3.0.5, antd@2.0.9, When doing routing, you can add the page number route to the browser by clicking the page number on multiple pages, but you still return to the home page after refreshing, or even though the browser address has changed, you are still on the original page number page and there is no jump. Please help. Can you do me a favor? Below is the code part

1, Route distribution

class Index extends React.Component {
    render () {
        return (
            <Router history={hashHistory}>
                <Route path="/" component={App}>
                    <IndexRoute component={Login}></IndexRoute>
                    <Route path="/finance/:page" component={Finance}></Route>
                </Route>
            </Router>
        );
    }
}

2, on the Finance page, hashHistory.push()

    handleTableChange = (pagination, filters, sorter) => {
        this.fetch({
            results: pagination.pageSize,
            page: pagination.current,
            // sortField: sorter.field,
            // sortOrder: sorter.order,
            ...filters,
        });
        // console.log(pagination)
        hashHistory.push(`/finance/${pagination.current}`);
    }

3, table component in Finance

<Table
    rowSelection={rowSelection}
    columns={this.columns}
    rowKey={record => record.wid}
    dataSource={this.state.data}
    pagination={this.state.pagination}
    loading={this.state.loading}
    onChange={this.handleTableChange}
/>
PHPz
PHPz

學習是最好的投資!

reply all(2)
劉奇

I solved it myself. I reloaded componentWillReceiveProps. In the end, the page will change when I refresh or roll back. I don’t know if this method is correct.

    componentWillReceiveProps(nextProps) {
        // console.log(nextProps);
        const { pagination, filters } = this.state;
        pagination.current = Number(nextProps.params.page);
        this.setState({
            pagination,
        });
        this.fetch({
            size: pagination.pageSize,
            page: pagination.current - 1,
            startDate: this.state.startDate,
            endDate: this.state.endDate,
            ...filters,
        });
    }
過去多啦不再A夢

Where is your setState that triggers react update?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template