Files
crawlab/frontend/src/components/table/pagination.ts
2021-07-15 21:37:37 +08:00

29 lines
546 B
TypeScript

import {SetupContext} from 'vue';
const usePagination = (props: TableProps, ctx: SetupContext) => {
const {emit} = ctx;
const onCurrentChange = (page: number) => {
const {pageSize} = props;
emit('pagination-change', {
page,
size: pageSize,
} as TablePagination);
};
const onSizeChange = (size: number) => {
const {page} = props;
emit('pagination-change', {
page,
size,
} as TablePagination);
};
return {
onCurrentChange,
onSizeChange,
};
};
export default usePagination;