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
<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>
<template>
<v-pagination :total="500" v-model="model"></v-pagination>
</template>
<script>
export default {
data() {
return {
model: 6
}
}
}
</script>
<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>
<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>
<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>
<template>
<v-pagination simple :total="50" v-model="model"></v-pagination>
</template>
<script>
export default {
data() {
return {
model: 2
}
}
}
</script>
<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#
Property | Description | Type | Default |
---|---|---|---|
value | current page number,two-way binding | number | - |
total | total number of data | number | 0 |
pageSize | number of data per page | number | - |
onChange | a callback function, can be executed when the page number is changing, and it takes the resulting page number and pageSize as its arguments | Function(page, pageSize) | noop |
showSizeChanger | determine whether pageSize can be changed | boolean | false |
pageSizeOptions | specify the sizeChanger selections | string[] | ['10', '20', '30', '40'] |
onShowSizeChange | a callback function, can be executed when pageSize is changing | Function(current, size) | noop |
showQuickJumper | determine whether you can jump to a page directly | boolean | false |
size | specify the size of Pagination , can be set to small | string | "" |
simple | whether to use simple mode | boolean | - |
showTotal | to display the total number and range | Function(total, range) | - |