Pagination

A long list can be divided into several pages by Pagination, and only one page will be loaded at a time.

When To Use#

  • When it will take a long time to load/render all items.

  • If you want to browse the data by switching in the pages.

<v-pagination :total="50" v-model="model"></v-pagination>

Examples

Basic pagination.

<template>
  <v-pagination :total="50" v-model="model" @onChange="onChange"></v-pagination>
</template>
<script>
  export default {
    data() {
      return {
        model: 1
      }
    },
    methods: {
      onChange(page) {
        console.log(page)
      }
    }
  }
</script>

More pages.

<template>
  <v-pagination :total="500" v-model="model"></v-pagination>
</template>
<script>
  export default {
    data() {
      return {
        model: 6
      }
    }
  }
</script>
  • 10 / page

Change pageSize.

<template>
  <v-pagination showSizeChanger :total="50" v-model="model" @onShowSizeChange="onShowSizeChange"></v-pagination>
</template>
<script>
  export default {
    data() {
      return {
        model: 3
      }
    },
    methods: {
      onShowSizeChange(page, pageSize) {
        console.log(page, pageSize)
      }
    }
  }
</script>

Jump to a page directly.

<template>
  <v-pagination showQuickJumper :total="500" v-model="model" @onChange="onChange"></v-pagination>
</template>
<script>
  export default {
    data() {
      return {
        model: 2
      }
    },
    methods: {
      onChange(page) {
        console.log(page)
      }
    }
  }
</script>
  • 10 / page
    Goto
    Total 1-10 of 50 items items

Mini size pagination.

<template>
  <section>
    <v-pagination size="small" :total="50"></v-pagination>
    <v-pagination size="small" :total="50" showSizeChanger showQuickJumper></v-pagination>
    <v-pagination size="small" :total="50" :showTotal="showTotal"></v-pagination>
  </section>
</template>
<style>
  #components-pagination-demo-mini .ant-pagination:not(:last-child) {
    margin-bottom: 24px;
  }
</style>
<script>
  export default {
    methods: {
      showTotal(total, range) {
        return `${range[0]}-${range[1]} of ${total} items`
      }
    }
  }
</script>
  • 5

Simple mode.

<template>
  <v-pagination simple :total="50" v-model="model"></v-pagination>
</template>
<script>
  export default {
    data() {
      return {
        model: 2
      }
    }
  }
</script>
    Total Total 50 items items

    Total 11-20 of 50 items items

You can show the total number of data by setting showTotal.

<template>
  <section>
    <v-pagination :total="50" v-model="model" :showTotal="showTotal1"></v-pagination>
    <br/>
    <v-pagination :total="50" v-model="model" :showTotal="showTotal2"></v-pagination>
  </section>
</template>
<script>
  export default {
    data() {
      return {
        model: 2
      }
    },
    methods: {
      showTotal1(total) {
        return `Total ${total} items`
      }
      ,showTotal2(total, range) {
        return `${range[0]}-${range[1]} of ${total} items`
      }
    }
  }
</script>

API#

PropertyDescriptionTypeDefault
valuecurrent page number,two-way bindingnumber-
totaltotal number of datanumber0
pageSizenumber of data per pagenumber-
onChangea callback function, can be executed when the page number is changing, and it takes the resulting page number and pageSize as its argumentsFunction(page, pageSize)noop
showSizeChangerdetermine whether pageSize can be changedbooleanfalse
pageSizeOptionsspecify the sizeChanger selectionsstring[]['10', '20', '30', '40']
onShowSizeChangea callback function, can be executed when pageSize is changingFunction(current, size)noop
showQuickJumperdetermine whether you can jump to a page directlybooleanfalse
sizespecify the size of Pagination, can be set to smallstring""
simplewhether to use simple modeboolean-
showTotalto display the total number and rangeFunction(total, range)-