@@ -99,17 +99,6 @@ function usePagination<R, P extends unknown[], FR>(
99
99
run ( ...mergerParams ) ;
100
100
} ;
101
101
102
- const total = computed < number > ( ( ) => get ( data . value , totalKey , 0 ) ) ;
103
- const current = computed (
104
- ( ) => ( params . value [ 0 ] as Record < string , number > ) [ currentKey ] ,
105
- ) ;
106
- const pageSize = computed (
107
- ( ) => ( params . value [ 0 ] as Record < string , number > ) [ pageSizeKey ] ,
108
- ) ;
109
- const totalPage = computed < number > ( ( ) =>
110
- get ( data . value , totalPageKey , Math . ceil ( total . value / pageSize . value ) ) ,
111
- ) ;
112
-
113
102
// changeCurrent change current page (current: number) => void
114
103
const changeCurrent = ( current : number ) => {
115
104
paging ( { [ currentKey ] : current } ) ;
@@ -120,6 +109,23 @@ function usePagination<R, P extends unknown[], FR>(
120
109
paging ( { [ pageSizeKey ] : pageSize } ) ;
121
110
} ;
122
111
112
+ const total = computed < number > ( ( ) => get ( data . value , totalKey , 0 ) ) ;
113
+ const current = computed ( {
114
+ get : ( ) => ( params . value [ 0 ] as Record < string , number > ) [ currentKey ] ,
115
+ set : ( val : number ) => {
116
+ changeCurrent ( val ) ;
117
+ } ,
118
+ } ) ;
119
+ const pageSize = computed ( {
120
+ get : ( ) => ( params . value [ 0 ] as Record < string , number > ) [ pageSizeKey ] ,
121
+ set : ( val : number ) => {
122
+ changePageSize ( val ) ;
123
+ } ,
124
+ } ) ;
125
+ const totalPage = computed < number > ( ( ) =>
126
+ get ( data . value , totalPageKey , Math . ceil ( total . value / pageSize . value ) ) ,
127
+ ) ;
128
+
123
129
return {
124
130
data,
125
131
params,
0 commit comments