我的问题是关于我想使用时的 Antd 分页控制索引



当我创建分页这个标签时,我想在发送 ajax 然后成功回调函数然后更改索引时控制它

我尝试使用onchange功能,然后更改当前数字,但仍然保持当前页面不使用

表标签具有分页

--这样

                                pagination={{
                                    total: total,
                                    pageSize: limit,
                           /*         onChange(current) {
                                        dispatch({
                                            type: '@LotteryBetRecord/turning',
                                            payload: {
                                                post: that.getSearchParames(),
                                                pageSize: limit,
                                                current: current - 1
                                            }
                                        })
                                    },*/
                                    onChange:(current,limit)=>{
                                        that.onChange.bind(this,current,limit)
                                    },
                                    showTotal: function () {
                                        return `共${total}条记录`
                                    }
                                }}
                            />

                    onConfirm={() => {
                        dispatch({
                            type: 'operational/betting',
                            payload: {
                                blist: JSON.stringify(betListValue),
                                callback: (res) => {
                                    if (res.error === 0) {
                                        message.success('success')
                                        that.search()
                                        that.onChange(2,10)
                                    }
                                }
                            }
                        })
                    }}

onChange(current,limit){
    const {dispatch} = this.props;
    dispatch({
        type: '@LotteryBetRecord/turning',
        payload: {
            post: this.getSearchParames(),
            pageSize: limit,
            current: current - 1
        }
    })
}

在 3.13.2 版本中,此组件中存在错误。相关问题在这里;https://github.com/ant-design/ant-design/issues/14875。 当您通过第二页时,您将填充数据源,但第二页似乎为空,并且仍然只有一页。检查较新版本,或者您可以使用以下解决方法;

dataSource={[...Array.from({length: (current - 1) * pageSize}), ...dataSource]}

最新更新