Skip to content

Commit cca5d9d

Browse files
authored
Update mixin-pagination.js
1 parent 8649a74 commit cca5d9d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/table/helpers/mixin-pagination.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { toInteger } from '../../../utils/number'
2+
13
export default {
24
props: {
35
perPage: {
@@ -13,12 +15,18 @@ export default {
1315
localPaging() {
1416
return this.hasProvider ? !!this.noProviderPaging : true
1517
},
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+
},
1624
paginatedItems() {
1725
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
2028
// Apply local pagination
21-
if (this.localPaging && !!perPage) {
29+
if (this.localPaging && perPage) {
2230
// Grab the current page of data (which may be past filtered items limit)
2331
items = items.slice((currentPage - 1) * perPage, currentPage * perPage)
2432
}

0 commit comments

Comments
 (0)