File tree 1 file changed +11
-3
lines changed
src/components/table/helpers
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { toInteger } from '../../../utils/number'
2
+
1
3
export default {
2
4
props : {
3
5
perPage : {
@@ -13,12 +15,18 @@ export default {
13
15
localPaging ( ) {
14
16
return this . hasProvider ? ! ! this . noProviderPaging : true
15
17
} ,
18
+ computedCurrentPage ( ) {
19
+ return Math . max ( toInteger ( this . currentPage , 10 ) || 1 , 1 )
20
+ } ,
21
+ computedPerPage ( ) {
22
+ Math . max ( toInteger ( this . perPage , 10 ) || 0 , 0 )
23
+ } ,
16
24
paginatedItems ( ) {
17
25
let items = this . sortedItems || this . filteredItems || this . localItems || [ ]
18
- const currentPage = Math . max ( parseInt ( this . currentPage , 10 ) || 1 , 1 )
19
- const perPage = Math . max ( parseInt ( this . perPage , 10 ) || 0 , 0 )
26
+ const currentPage = this . computedCurrentPage
27
+ const perPage = this . computedPerPage
20
28
// Apply local pagination
21
- if ( this . localPaging && ! ! perPage ) {
29
+ if ( this . localPaging && perPage ) {
22
30
// Grab the current page of data (which may be past filtered items limit)
23
31
items = items . slice ( ( currentPage - 1 ) * perPage , currentPage * perPage )
24
32
}
You can’t perform that action at this time.
0 commit comments