mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 11:07:52 +08:00
fix: Pagination 切换页码后每页显示重置问题 (#4298)
This commit is contained in:
parent
e2deb3c891
commit
8829f6346f
@ -4,6 +4,7 @@
|
||||
* @Date: 2021-11-01 16:57:38
|
||||
*/
|
||||
import React from 'react';
|
||||
import isInteger from 'lodash/isInteger';
|
||||
import {localeable, LocaleProps} from '../locale';
|
||||
import {themeable, ThemeProps} from '../theme';
|
||||
import {autobind} from '../utils/helper';
|
||||
@ -122,12 +123,20 @@ export class Pagination extends React.Component<
|
||||
this.handlePageNums = this.handlePageNums.bind(this);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: PaginationProps) {
|
||||
if (prevProps.perPage !== this.props.perPage) {
|
||||
const perPage = Number(this.props.perPage);
|
||||
this.setState({perPage: isInteger(perPage) ? perPage : 10});
|
||||
}
|
||||
}
|
||||
|
||||
handlePageNumChange(page: number, perPage?: number) {
|
||||
const props = this.props;
|
||||
if (props.disabled) {
|
||||
const {disabled, onPageChange} = this.props;
|
||||
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
props.onPageChange && props.onPageChange(page, perPage);
|
||||
onPageChange?.(page, perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -665,7 +665,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
: this.search(undefined, undefined, true, true);
|
||||
action.close && this.closeTarget(action.close);
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(e => {
|
||||
if (throwErrors || action.countDown) {
|
||||
throw e;
|
||||
}
|
||||
@ -1693,6 +1693,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
||||
lastPage: lastPage,
|
||||
hasNext: store.hasNext,
|
||||
mode: store.mode,
|
||||
perPage: store.perPage,
|
||||
onPageChange: this.handleChangePage
|
||||
}
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user