mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-21 21:41:53 +00:00
Change subTotal to a computed property.
This commit is contained in:
parent
6148343d9c
commit
ceeb1c37c2
1 changed files with 5 additions and 5 deletions
|
|
@ -46,7 +46,6 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
subTotal: 0,
|
||||
totalItems: 0,
|
||||
currentPage: 1,
|
||||
currentSize: parseInt(this.mdSize, 10)
|
||||
|
|
@ -72,14 +71,16 @@
|
|||
},
|
||||
shouldDisable() {
|
||||
return this.currentSize * this.currentPage >= this.totalItems;
|
||||
},
|
||||
subTotal() {
|
||||
const sub = this.currentPage * this.currentSize;
|
||||
|
||||
return sub > this.mdTotal ? this.mdTotal : sub;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitPaginationEvent() {
|
||||
if (this.canFireEvents) {
|
||||
const sub = this.currentPage * this.currentSize;
|
||||
|
||||
this.subTotal = sub > this.mdTotal ? this.mdTotal : sub;
|
||||
this.$emit('pagination', {
|
||||
size: this.currentSize,
|
||||
page: this.currentPage
|
||||
|
|
@ -109,7 +110,6 @@
|
|||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
this.subTotal = this.currentPage * this.currentSize;
|
||||
this.mdPageOptions = this.mdPageOptions || [10, 25, 50, 100];
|
||||
this.currentSize = this.mdPageOptions.includes(this.currentSize) ? this.currentSize : this.mdPageOptions[0];
|
||||
this.canFireEvents = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue