Skip to content

Commit d26c65d

Browse files
committed
fix: CPagination: add items amount computed property
1 parent 993ffbd commit d26c65d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/Pagination/CPagination.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,23 @@
181181
lastItem () {
182182
return this.range >= this.pages ? this.pages : this.range-this.afterDots
183183
},
184+
itemsAmount () {
185+
return this.pages < this.computedLimit ? this.pages : this.computedLimit
186+
},
184187
items () {
185188
if (this.activePage - this.maxPrevItems <= 1 ) {
186-
return Array.from({ length: this.computedLimit }, (v, i) => i + 1 )
189+
return Array.from({ length: this.itemsAmount }, (v, i) => i + 1 )
187190
} else {
188-
return Array.from({length: this.computedLimit}, (v, i) => {
191+
return Array.from({length: this.itemsAmount}, (v, i) => {
189192
return this.lastItem - i
190193
}).reverse()
191194
}
192195
}
193196
},
194197
methods: {
195198
onWrapperResize (el) {
196-
el.clientWidth > 600 ? this.rwd = this.size :
197-
el.clientWidth > 400 ?
198-
this.rwd = 'md' : this.rwd = 'sm'
199+
const responsiveSize = el.clientWidth > 400 ? 'md' : 'sm'
200+
this.rwd = el.clientWidth > 600 ? this.size : responsiveSize
199201
},
200202
setPage (number) {
201203
if (number !== this.activePage) {

0 commit comments

Comments
 (0)