Skip to content

Pagination 分页组件

当数据量过多时,使用分页分解数据。

温馨提示

本项目参考了 Wot-UI 开源项目的组件开发方式,基于 Vue 3 和 TypeScript 实现了自定义组件。目前该组件仍处于测试阶段。
感谢 Wot-UI 开源项目及其团队成员的贡献,他们的组件开发思路为本项目提供了宝贵地参考。如果需要了解更多组件开发细节,可以参考Wot-UI的 pagination组件 的代码实现。

平台差异说明

APP(vue)H5微信小程序

基本使用示例

html
<!-- 全局使用 -->
<hy-pagination v-model="value" :total="999"></hy-pagination>
<!-- 单个组件引入 -->
<HyPagination v-model="value" :total="999"></HyPagination>
ts
import { HyPagination } from "hy-app";
import { ref } from "vue";

const value = ref<number>(1)

显示图标

  • 通过设置show-icon,将分页导航展示为Icon图标
html
<template>
    <hy-pagination v-model="value" :total="999" show-icon></hy-pagination>
</template>

文字提示

  • 通过设置show-message,展示文字提示
html
<template>
    <hy-pagination v-model="value" :total="999" show-message></hy-pagination>
</template>

一页展示数

  • 通过设置pageSize,显示一页展示数量
html
<template>
    <hy-pagination v-model="value" :total="999" :page-size="20"></hy-pagination>
</template>

设置展示文字

  • 通过设置prevText,显示上一页按钮文本
  • 通过设置nextText,显示下一页按钮文本
html
<template>
    <hy-pagination v-model="value" :total="999" prevText="上" nextText="下"></hy-pagination>
</template>

API

参数说明类型默认值
v-model当前页number1
totalPage总页数,如果有total,则优先使用total计算页数number1
showIcon是否展示分页Iconbooleanfalse
showMessage是否展示文字提示booleanfalse
total总数据个数number-
pageSize分页大小number10
prevText上一页按钮文字string上一页
nextText下一页按钮文字string下一页
hideIfOnePage总页数只有一页时是否隐藏booleantrue
customStyle定义需要用到的外部样式CSSProperties-

Events

事件名说明回调参数
change值修改事件value: value为当前数
09:58