1
0
Fork 0

Paginated spells list

This commit is contained in:
Joe Wroten 2017-05-08 17:34:42 -04:00
parent 99507b0884
commit 892fa05c42

View file

@ -12,15 +12,33 @@
<big>Level</big> <big>Level</big>
</th> </th>
</tr> </tr>
<tr>
<td colspan="3">
<q-pagination
v-model="page"
:max="pageMax"
></q-pagination>
</td>
</tr>
</thead> </thead>
<tbody> <tbody>
<tr <tr
is="spell-item" is="spell-item"
v-for="spell in spells" v-for="spell in pagedSpells"
:spell="spell" :spell="spell"
> >
</tr> </tr>
</tbody> </tbody>
<tfoot>
<tr>
<td colspan="3">
<q-pagination
v-model="page"
:max="pageMax"
></q-pagination>
</td>
</tr>
</tfoot>
</table> </table>
</template> </template>
@ -31,9 +49,25 @@ import SpellItem from './Spellitem'
Vue.component('spell-item', SpellItem) Vue.component('spell-item', SpellItem)
export default { export default {
computed: {
pageMax () {
return this.spells.length / this.perPage
},
pagedSpells () {
let min = this.page * this.perPage - this.perPage
let max = min + this.perPage
return this.spells.slice(min, max)
}
},
props: [ props: [
'spells' 'spells'
] ],
data () {
return {
perPage: 10,
page: 1
}
}
} }
</script> </script>