avoiding mutating prop mdPageOptions (fix #830)

This commit is contained in:
Lucas Fernandes 2017-06-22 17:23:36 -03:00
parent 50e4bbf5dc
commit 567440a584

View file

@ -2,7 +2,7 @@
<div class="md-table-pagination">
<span class="md-table-pagination-label">{{ mdLabel }}:</span>
<md-select v-model="currentSize" md-menu-class="md-pagination-select" @change="changeSize" v-if="mdPageOptions">
<md-select v-model="currentSize" md-menu-class="md-pagination-select" @change="changeSize" v-if="mdPageOptions !== false">
<md-option v-for="amount in mdPageOptions" :key="amount" :value="amount">{{ amount }}</md-option>
</md-select>
@ -26,7 +26,10 @@
type: [Number, String],
default: 10
},
mdPageOptions: [Array, Boolean],
mdPageOptions: {
type: [Array, Boolean],
default: () => [10, 25, 50, 100]
},
mdPage: {
type: [Number, String],
default: 1
@ -110,8 +113,11 @@
},
mounted() {
this.$nextTick(() => {
this.mdPageOptions = this.mdPageOptions || [10, 25, 50, 100];
this.currentSize = this.mdPageOptions.includes(this.currentSize) ? this.currentSize : this.mdPageOptions[0];
if (this.mdPageOptions) {
this.currentSize = this.mdPageOptions.includes(this.currentSize) ? this.currentSize : this.mdPageOptions[0];
} else {
this.currentSize = 0;
}
this.canFireEvents = true;
});
}