Skip to content
On this page

Pagination 分页

基础使用

Total 50
  • 1
  • 2
  • 3
  • 4
  • 5
Go to
vue
<template>
  <k-page :total="total" v-model="currentPage" @current-change="changePage" />
</template>

<script setup>
import { ref } from 'vue';

const total = ref(50);
const currentPage = ref(1);

const changePage = (page) => {
  console.log('page: ', page);
};
</script>

切换页码

Total 50
  • 1
  • 2
  • 3
  • 4
  • 5
Go to
vue
<template>
  <k-page
    :total="total" show-size v-model="currentPage"
    @current-change="changePage" @size-change="sizeChange"
  />
</template>

<script setup>
import { ref } from 'vue';

const total = ref(50);
const currentPage = ref(1);

const changePage = (page) => {
  console.log('page: ', page);
};

const sizeChange = (size) => {
  console.log('当前size: ', size);
};
</script>

小型分页

设置small, 可设置小型分页

Total 50
  • 1
  • 2
  • 3
  • 4
  • 5
Go to
vue
<template>
  <k-page
    :total="total" small
    v-model="currentPage" @current-change="changePage"
  />
</template>

<script setup>
import { ref } from 'vue';

const total = ref(50);
const currentPage = ref(1);

const changePage = (page) => {
  console.log('page: ', page);
};
</script>

设置最大页码按钮数

默认情况下,当总页数超过 7 页时,Pagination 会折叠多余的页码按钮。 通过 pager-count 属性可以设置最大页码按钮数。

Total 500
  • 1
  • 2
  • 3
  • 4
  • 50
Go to
vue
<template>
  <k-page
    :total="total" :pager-count="5"
    v-model="currentPage" @current-change="changePage"
  />
</template>

<script setup>
import { ref } from 'vue';

const total = ref(500);
const currentPage = ref(1);

const changePage = (page) => {
  console.log('page: ', page);
};
</script>

Pagination 属性

Pagination 事件