分页

基础用法

  • 示例:
点击查看代码
<template>
  <div>
    <ZPagination v-model:current="current1" :total="50" />
  </div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
  setup() {
    const current1=ref(3)
    return {
      current1
    }
  },
})
</script>

更多分页

  • 示例:
点击查看代码
<template>
  <ZPagination
    v-model:current="current"
    v-model:pageSize="pageSize"
    show-size-changer
    @showSizeChange="onShowSizeChange"
    :total="total"
  >
  </ZPagination>
</template>
<script>
  import { defineComponent, ref } from 'vue'
  export default defineComponent({
    setup() {
      const current = ref(2)
      const total = ref(500)
      const pageSizeRef = ref(10)
      const onShowSizeChange = (current, pageSize) => {
      console.log(current, pageSize);
    }
      return {
        current,
        total,
        pageSize: pageSizeRef,
        onShowSizeChange
      }
    }
  })
</script>
    

简单版本

  • 示例:
点击查看代码
<template>
  <div>
    <ZPagination v-model:current="current" :total="50" simple />
  </div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
  setup() {
    const current=ref(2)
    return {current}
  },
})
</script>

跳转版本

  • 示例:
点击查看代码
<template>
  <div>
    <ZPagination v-model:current="current" :total="50" show-quick-jumper />
  </div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
  setup() {
    const current=ref(2)
    return {current}
  },
})
</script>

参数

参数说明类型默认值
current(v-model)当前页数number1
pageSize(v-model)每页条数number-
pageSizeOptions指定每页可以显示多少条array['10', '20', '50', '100']
showLessItems是否显示较少页面内容booleanfalse
showQuickJumper是否可以快速跳转至某页booleanfalse
total数据总数number0
defaultPageSize默认的每页条数number10
hideOnSinglePage只有一页时是否隐藏分页器booleanfalse
showSizeChanger是否可以改变 pageSizebooleanfalse
simple当添加该属性时,显示为简单分页boolean-

事件

事件说明回调参数
showSizeChangepageSize 变化的回调Function(current, size)
change页码改变的回调,参数是改变后的页码及每页条数Function(page, pageSize)
Last Updated:
Contributors: jixuanyu