Pagination API
Pagination extension.
const { ...ReturnValues } = usePagination<R, P>(Service, Options);
See also: Pagination
Note
The following APIs are a superset of the Public API. Unless otherwise specified, they are consistent with the Public API.
Return Values
current
Type:
Ref<number>Default:
1The current page number. We internally listen to this value, so when you directly modify
current, thechangeCurrentmethod will be triggered automatically. Therefore, you can use it together withv-model.
pageSize
Type:
Ref<number>Default:
10The number of items per page. We internally listen to this value, so when you directly modify
pageSize, thechangePageSizemethod will be triggered automatically. Therefore, you can use it together withv-model.
total
Type:
Ref<number>Default:
0The total number of data.
totalPage
Type:
Ref<number>Default:
0The total number of pages, which may be incorrect if the
totalandpageSizeare not set correctly.
changeCurrent
Type:
(current: number) => voidChange the current page number.
changePageSize
Type:
(pageSize: number) => voidChange the number of items per page.
changePagination
Type:
(current: number, pageSize: number) => voidChange both the page number and the number of items per page.
Options
pagination
Type:
{ currentKey?: string; pageSizeKey?: string; totalKey?: string; totalPageKey?: string; }Details:
Tips
totalKey and totalPageKey are implemented using lodash.get, so you can pass in a path to an object property to retrieve the value. For more details, please refer to the lodash documentationopen in new window.
| pagination Field | Description | Defaults |
|---|---|---|
| currentKey | You can use this value to specify the property name of the current page number parameter in the API. parameter. | 'current' |
| pageSizeKey | You can use this value to specify the property name of the number of items per page parameter in the API. | 'pageSize' |
| totalKey | Specify the path of the total property in the data object. | 'total' |
| totalPageKey | Specify the path of the totalPage property in the data object. | 'totalPage' |
