You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.1 KiB

  1. <template>
  2. <v-bottom-navigation
  3. app
  4. absolute
  5. hide-on-scroll
  6. >
  7. <v-btn
  8. :disabled="isFirstPage"
  9. @click="updatePage(page - 1)"
  10. >
  11. <span>Prev</span>
  12. <v-icon>{{ mdiChevronLeft }}</v-icon>
  13. </v-btn>
  14. <v-btn
  15. :disabled="isLastPage"
  16. @click="updatePage(page + 1)"
  17. >
  18. <span>Next</span>
  19. <v-icon>{{ mdiChevronRight }}</v-icon>
  20. </v-btn>
  21. </v-bottom-navigation>
  22. </template>
  23. <script lang="ts">
  24. import Vue from 'vue'
  25. import { mdiChevronLeft, mdiChevronRight } from '@mdi/js'
  26. export default Vue.extend({
  27. props: {
  28. total: {
  29. type: Number,
  30. default: 1,
  31. required: true
  32. }
  33. },
  34. data() {
  35. return {
  36. mdiChevronLeft,
  37. mdiChevronRight
  38. }
  39. },
  40. computed: {
  41. page(): number {
  42. // @ts-ignore
  43. return parseInt(this.$route.query.page, 10)
  44. },
  45. isFirstPage(): boolean {
  46. return this.page === 1
  47. },
  48. isLastPage(): boolean {
  49. return this.page === this.total || this.total === 0
  50. }
  51. },
  52. methods: {
  53. updatePage(page: number) {
  54. this.$router.push({ query: { page: page.toString() }})
  55. }
  56. }
  57. })
  58. </script>