diff --git a/src/components/Spelllist.vue b/src/components/Spelllist.vue index 5c8e350..e125e60 100644 --- a/src/components/Spelllist.vue +++ b/src/components/Spelllist.vue @@ -51,7 +51,8 @@ Vue.component('spell-item', SpellItem) export default { computed: { pageMax () { - return this.spells.length / this.perPage + let trueMax = this.spells.length / this.perPage + return trueMax < 1 ? 1 : trueMax }, pagedSpells () { let min = this.page * this.perPage - this.perPage @@ -59,6 +60,13 @@ export default { return this.spells.slice(min, max) } }, + watch: { + pageMax (newPageMax) { + if (this.page > newPageMax) { + this.page = newPageMax + } + } + }, props: [ 'spells' ],