perf(分页模块): 优化分页代码
1.将重复代码放进hooks
This commit is contained in:
parent
fba0fe8b77
commit
3d7394217f
19
src/hooks/pagination.ts
Normal file
19
src/hooks/pagination.ts
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
export default function usePagination(initValue = false) {
|
||||
const pagination: any = {
|
||||
pages: 1,
|
||||
size: 10,
|
||||
current: 1,
|
||||
total: 0,
|
||||
};
|
||||
const setPagination = (value: any) => {
|
||||
pagination.pages = value.page;
|
||||
pagination.size = value.size;
|
||||
pagination.current = value.current;
|
||||
pagination.total = value.total;
|
||||
};
|
||||
return {
|
||||
pagination,
|
||||
setPagination,
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user