Pagination
页面导航、尺寸选择、快速输入和自定义元素。
何时使用
分页将大量帖子分为多个页面。它报告页码和大小,应用程序控制数据的加载、过滤和输出。您可以对表使用内置分页 Table。
在前缀示例中可以切换全局 ConfigProvider.prefixCls 或局部 prefixCls。当前页、已输入的页码和页码按钮的尺寸都会保留。每页条数选择器使用全局前缀。
页码和样本大小
total - 记录数,pageSize - 页上的记录数,current 从1开始。defaultCurrent 和 defaultPageSize 读取一次。对于外部控制和状态保存,请使用 bind:current 和 bind:pageSize。
| 问题 | 设置 | 示例 |
|---|---|---|
| 对帖子进行分页 | total、pageSize |
主要场景 |
| 选择记录数 | showSizeChanger、pageSizeOptions |
尺寸选择 |
| 直接转到号码 | showQuickJumper |
直接过渡 |
| 将状态保存到外部 | bindings | 外部条件 |
| 显示数量和范围 | 片段 showTotal |
概括 |
更改大小时,包会保留页码并将其限制为新范围。 onChange 获取page和 pageSize; Ant Design 6.7 中的第三个参数 info.recommendPage 还没有出现。如果您需要保持特定条目的可见性,请计算应用程序中所需的数量。
请求应该传递一个匹配的页面/pageSize 对。更换过滤器时,更新 total 和页码;先前请求的延迟响应不应替换新数据。
演示和附加元素
showSizeChanger 启用选择。如果缺少 prop,则当 total 高于 totalBoundaryShowSizeChanger(默认为 50)时,它会出现。使用 showSizeChanger.options 为每页条数设置自定义标签。该对象也接受 Select 的其他属性。components.sizeChanger 可传入 具有 value、options、disabled 和 onChange 的自定义元素的片段。
showQuickJumper 接受 boolean 或 goButton 对象。simple 包括紧凑的表示; readOnly 对象禁用数字编辑。 showLessItems 减少相邻页面的数量,hideOnSinglePage 在存在单个页面时隐藏导航。
itemRender 接收数字、类型、准备好的 originalElement 片段和带有 onClick、label、disabled 和活动处理程序的 info。替换完成的按钮时,将这些属性保存在您自己的控件上。过渡图标也接受片段。详情见你的渲染。
的尺寸、可用性和限制
align 指定 start/center/end。size 支持当前 large/medium/small。responsive 运行无需显式设置 ConfigProvider 的 size 或 componentSize。在启用了 Source 引擎的主题中,xs 边框取自 theme.token.screenXSMax;无主题的普通模式使用标准 575px。嵌套提供程序继承阈值, theme.inherit:false 返回标准阈值。应用新设计令牌(design tokens)无需重新安装,从而保存页面和草稿跳线。
阈值示例 比较 639px 和 575px。它在独立的 Svelte 上下文中运行,因为画廊的通用 componentSize 压倒了 responsive 能力。在服务器上,本示例的 shell 显示了一个存根; Pagination本身支持SSR,并且在mount前不添加mini。 SSR 已拒绝不正确的屏幕*边界顺序。
responsive 添加了一个迷你类,但其本身并不能保证较小的高度,如固定的 Ant Design 6.6.8 中所示。对于固定的小尺寸,请指定“small”。快速跳转字段被标准CSS隐藏,宽度最大为576px,无论 theme.token.screenXSMax 如何;主要导航仍然存在。
根目录是nav,页面在列表中。提供清晰的 aria-label,特别是当页面上有多个分页时。本机渲染必须保持键盘可访问性和 disabled。
ConfigProvider.pagination 设置一般语义默认值、showSizeChanger 及其阈值。组件分页标记会更改项目的大小和状态。class 指的是 ul,语义 root 指的是 nav。 prefixCls 更改 DOM 类和样式。切换前缀时,紧凑主题也会保留页码按钮的尺寸。 NativeElement-ref 尚不可用。
示例
基本分页
五页,无法选择尺寸。活动页面的数量可通过 aria-current 获得,转换由本机按钮执行。
<script lang="ts">
import { Pagination } from '@woodger/antd';
</script>
<Pagination total={50} showSizeChanger={false} aria-label={("基本页面")} />
结盟
align 将分页定位在可用行的开头、中心或结尾。
<script lang="ts">
import { Pagination, type PaginationProps } from '@woodger/antd';
let align = $state<PaginationProps['align']>('center');
</script>
<style>
label {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin-bottom: 16px;
}
</style>
<label>{("页面对齐 ")}<select bind:value={align}>
<option value="start">
{("一开始")}
</option>
<option value="center">
{("居中")}
</option>
<option value="end">{("在最后")}</option>
</select></label>
<Pagination total={50} {align} showSizeChanger={false} aria-label={("对齐页面")} />
很多页
使用省略号跳转可以缩短长列表。 showLessItems 减少相邻页面的数量。
<script lang="ts">
import { Pagination, Checkbox } from '@woodger/antd';
let compact = $state(false);
</script>
<style> .controls { margin-bottom:16px; }
</style>
<div
class="controls"
><Checkbox
bind:checked={compact}
>{("相邻页数较少")}</Checkbox></div>
<Pagination total={5000} defaultCurrent={6} showLessItems={compact} showSizeChanger={false}
aria-label={("长页面列表")} />
参赛作品数量
showSizeChanger.options 为每页条数提供标签。bind:pageSize 和 bind:current 保存数值,处理函数显示两个事件。
<script lang="ts">
import { Pagination } from '@woodger/antd';
let current = $state(2);
let pageSize = $state(10);
let events = $state<string[]>([]);
</script>
<style>
output {
display: block;
margin-top: 16px;
overflow-wrap: anywhere;
}
</style>
<Pagination total={137} bind:current bind:pageSize
showSizeChanger={{
'aria-label': ("示例页面上的帖子"),
options: [
{ value: 10, label: ("每页 10 条记录") },
{ value: 20, label: ("每页 20 条记录") },
{ value: 50, label: ("每页 50 条记录") }
]
}}
onShowSizeChange={(page, size) => { events = [...events, `尺寸: ${page}/${size}`].slice(-4); }}
onChange={(page, size) => { events = [...events, `页: ${page}/${size}`].slice(-4); }}
aria-label={("尺寸选择页面")}
/>
<output
aria-label={("分页大小状态")}
>{("页 ")}{current}{(", 经过 ")}{pageSize}</output>
<output aria-label={("分页大小事件")}>{(events.join(' → ')
|| ("没有活动"))}</output>
快速跳跃
showQuickJumper 接受 Enter 或 goButton 确认。在窄屏幕上,该字段隐藏标准 responsive CSS。
<script lang="ts">
import { Pagination } from '@woodger/antd';
let current = $state(1);
let confirmed = $state(1);
</script>
<style>
.stack {
display: grid;
gap: 24px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="stack">
<Pagination total={500} bind:current showSizeChanger={false} showQuickJumper
aria-label={("快速跳转进入")} />
<Pagination
total={500}
bind:current={confirmed}
showSizeChanger={false}
showQuickJumper={{ goButton: "去" }}
aria-label={("通过按钮快速跳跃")}
/>
</div>
<output aria-label={("快速分页页面")}>Enter: {current}{(";按钮: ")}{confirmed}</output>
small
medium
large
方面
该包装可接受 small、medium 和 large。medium 适合常规尺码;设置本地组件优先于全局组件。
<script lang="ts">
import { Pagination, type ComponentSize } from '@woodger/antd';
const sizes: readonly ComponentSize[] = ['small', 'medium', 'large'];
</script>
<style>
.stack {
display: grid;
gap: 24px;
}
p {
margin: 0 0 12px;
color: var(--ant-color-text-secondary);
}
</style>
<div class="stack">
{#each sizes as size (size)}
<div><p>{(size)}</p><Pagination total={50} {size} showSizeChanger={false}
aria-label={("页数 " + String((size)) + "")} /></div>
{/each}
</div>
简易模式
simple 显示当前页和总页数。 readOnly 删除数字编辑,保留转换按钮。
<script lang="ts">
import { Pagination } from '@woodger/antd';
let current = $state(2);
let readOnly = $state(2);
</script>
<style>
.stack {
display: grid;
gap: 24px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="stack">
<Pagination total={500} simple bind:current showSizeChanger={false}
aria-label={("简单页面")} />
<Pagination total={500} simple={{ readOnly: true }} bind:current={readOnly}
showSizeChanger={false} aria-label={("无需打字的简单页面")} />
</div>
<output
aria-label={("简单的数字分页")}
>{("输入: ")}{current}{(";没有输入: ")}{readOnly}</output>
应用状态
双向绑定存储分页之外的数字。应用程序按钮返回第一页。
<script lang="ts">
import { Pagination, Button } from '@woodger/antd';
let current = $state(3);
</script>
<style>
.footer {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-top: 16px;
}
</style>
<Pagination total={50} bind:current showSizeChanger={false} aria-label={("托管页面")} />
<div class="footer">
<Button onclick={() => { current = 1; }}>
{("返回第一页")}
</Button>
<output
aria-label={("托管号码分页")}
>{("页 ")}{current}</output>
</div>
总记录数
showTotal - 带有当前页面的总边框和包含边框的 Svelte Snippet。
<script lang="ts">
import { Pagination } from '@woodger/antd';
</script>
<Pagination total={137} defaultCurrent={3} showSizeChanger={false} aria-label={("摘要页面")}>
{#snippet showTotal(total: number, range: [number, number])}
<span>{(range[0])}–{(range[1])}{(" 从 ")}{(total)}{(" 记录")}</span>
{/snippet}
</Pagination>
所有主要功能
一行结合了总量、尺寸选择、快速导航和常规页面按钮。
<script lang="ts">
import { Pagination } from '@woodger/antd';
let current = $state(1);
let pageSize = $state(10);
</script>
<Pagination total={500} bind:current bind:pageSize showSizeChanger showQuickJumper
aria-label={("完整分页")}>
{#snippet showTotal(total: number, range: [number, number])}{(range[0])}–{(range[1])}{(" 从 ")}{(total)}{/snippet}
</Pagination>
您自己的转换按钮
itemRender 获取 originalElement 和 info。其原生按钮使用 info.onClick 和 info.disabled;其余元素保留标准渲染器。
<script lang="ts">
import type { Snippet } from 'svelte';
import { Pagination, type PaginationItemInfo, type PaginationItemType } from '@woodger/antd';
let current = $state(1);
</script>
<style>
button {
border:0;
background:transparent;
color:inherit;
font:inherit;
cursor:pointer;
padding:0 6px;
}
button:disabled {
color: var(--ant-color-text-disabled);
cursor: not-allowed;
}
button:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet itemRender(
page: number,
type: PaginationItemType,
originalElement: Snippet,
info: PaginationItemInfo
)}
{#if type === 'prev' || type === 'next'}
<button type="button" disabled={info.disabled} aria-label={(info.label)}
onclick={info.onClick}>{(type === 'prev' ? "后退" : "更远")}</button>
{:else}
{@render originalElement()}
{/if}
{/snippet}
<Pagination total={50} bind:current showSizeChanger={false} {itemRender}
aria-label={("自定义页面转换")} />
<output
aria-label={("你的渲染器的数量 分页")}
>{("页 ")}{current}</output>
您选择的尺寸
components.sizeChanger 接受带有 options、value、disabled 和 onChange 的 Snippet。该示例使用可用的本机选择。
<script lang="ts">
import { Pagination, Checkbox, type PaginationSizeChangerInfo } from '@woodger/antd';
let pageSize = $state(10);
let disabled = $state(false);
</script>
<style>
.controls { margin-bottom:16px; }
select {
max-width: 100%;
color: inherit;
background: var(--ant-color-bg-container);
font: inherit;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet sizeChanger(info: PaginationSizeChangerInfo)}
<select class={info.class} value={info.value} disabled={info.disabled}
aria-label={("自定义页面尺寸")}
onchange={event => info.onChange(Number(event.currentTarget.value))}>
{#each info.options as option (option.value)}
<option
value={option.value}
>{typeof option.label === 'string' ? option.label : option.value}</option>
{/each}
</select>
{/snippet}
<div class="controls">
<Checkbox bind:checked={disabled}>
{("禁用尺寸更改器")}
</Checkbox>
</div>
<Pagination total={137} bind:pageSize {disabled} showSizeChanger pageSizeOptions={[10, 20, 50]}
components={{ sizeChanger }} aria-label={("您可以选择尺寸的页面")} />
<output
aria-label={("自定义尺寸分页")}
>{("经过 ")}{pageSize}</output>
语义 styles 和 ConfigProvider
常规分页配置指定 root 和大小调整行为。本地 styles 为 items 添加样式。
<script lang="ts">
import { Pagination, ConfigProvider } from '@woodger/antd';
</script>
<ConfigProvider pagination={({
showSizeChanger: false,
classNames: { root: 'provider-pagination-root' },
styles: {
root: `
padding: 12px;
border: 1px solid var(--ant-color-primary-border);
border-radius: 8px;
`
}
})}>
<Pagination total={50} defaultCurrent={2} aria-label={("设计页面")}
classNames={{ item: 'semantic-pagination-item' }}
styles={({ props }) => ({ item: props.total ? 'border-radius:50%' : '' })}
/>
</ConfigProvider>
组件代币
本地主题会更改常规 items 的大小和活动页面的颜色。相邻卡片的主题被保留。
<script lang="ts">
import { Pagination, ConfigProvider, theme } from '@woodger/antd';
const tokens = theme.useToken();
let itemSize = $state(36);
</script>
<style>
label {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
margin-bottom: 16px;
}
</style>
<label>{("页面元素大小 ")}<input
type="range"
min="28"
max="44"
bind:value={itemSize}
/>
<output>{itemSize}px</output>
</label>
<ConfigProvider theme={{
cssVar: {}, components: {
Pagination: {
itemSize,
itemActiveBg: tokens.token.colorSuccessBg,
itemActiveColor: tokens.token.colorSuccess
}
}
}}>
<Pagination total={50} size="medium" showSizeChanger={false} aria-label={("具有自己主题的页面")} />
</ConfigProvider>
不可用状态
disabled 禁用按钮和标准尺寸选择。可以在不丢失号码的情况下切换设置。
<script lang="ts">
import { Pagination, Checkbox } from '@woodger/antd';
let disabled = $state(true);
</script>
<style> .controls { margin-bottom:16px; }
</style>
<div
class="controls"
><Checkbox
bind:checked={disabled}
>{("不可用的分页")}</Checkbox></div>
<Pagination total={137} defaultCurrent={2} {disabled} showSizeChanger
aria-label={("不可用的页面")} />
所有条目均放置在一页上;导航已隐藏。
单页
如果所有帖子都适合一页,则 hideOnSinglePage 会删除整个导航。
<script lang="ts">
import { Pagination, Checkbox } from '@woodger/antd';
let hide = $state(true);
</script>
<style>
.controls { margin-bottom:16px; }
p {
margin: 16px 0 0;
color: var(--ant-color-text-secondary);
}
</style>
<div
class="controls"
><Checkbox
bind:checked={hide}
>{("隐藏一页")}</Checkbox></div>
<Pagination total={7} hideOnSinglePage={hide} showSizeChanger={false}
aria-label={("单页")} />
<p>{(hide ? "所有条目均放置在一页上;导航已隐藏。" : "显示导航。")}</p>
本地化和 RTL
ConfigProvider 继承方向和区域设置。可用的英文按钮名称仅适用于该卡。
<script lang="ts">
import { Pagination, Checkbox, ConfigProvider, enUS } from '@woodger/antd';
let rtl = $state(false);
</script>
<style> .controls { margin-bottom:16px; }
</style>
<div class="controls"><Checkbox bind:checked={rtl}>RTL Pagination</Checkbox></div>
<ConfigProvider locale={enUS} direction={rtl ? 'rtl' : 'ltr'}>
<Pagination total={50} showSizeChanger={false} aria-label={("本地化页面")} />
</ConfigProvider>
后分页
使用 bind:current/pageSize 和记录范围浏览脚本。这张卡的状况与审查无关。
<script lang="ts">
import { Pagination } from '@woodger/antd';
let current = $state(1);
let pageSize = $state(10);
</script>
<style>
output {
display: block;
margin-top: 16px;
}
</style>
<Pagination total={137} bind:current bind:pageSize aria-label={("帖子页面")}>
{#snippet showTotal(total: number, range: [number, number])}{(range[0])}–{(range[1])}{(" 从 ")}{(total)}{/snippet}
</Pagination>
<output
aria-label={("后分页")}
>{("页: ")}{current}{("。页面上的条目: ")}{pageSize}.</output>
更改前缀后,页码按钮的尺寸、当前页和输入的页码都会保留。 每页条数选择器使用全局前缀。
CSS 分页前缀
通用命名空间ConfigProvider和本地 prefixCls;当名称更改时,组件的状态将被保留。
<script lang="ts">
import { Checkbox, ConfigProvider, Pagination } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-pagination' : '');
let current = $state(2);
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("通用前缀分页套件")}</Checkbox>
<Checkbox bind:checked={local}>{("本地前缀分页")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'pagination-theme' } }}>
<div class="prefix-stage">
<Pagination prefixCls={localPrefix} bind:current total={100} showQuickJumper
showSizeChanger={false} aria-label={("带前缀的分页")} />
<output aria-label={("带前缀的分页页面")}>{("页: ")}{current}</output>
</div>
</ConfigProvider>
<output
aria-label={("CSS 前缀分页")}
>{("一般的: ")}{prefix}{(";当地的: ")}{(localPrefix
|| ("来自提供商"))}</output>
<p>
{("更改前缀后,页码按钮的尺寸、当前页和输入的页码都会保留。")}
{("每页条数选择器使用全局前缀。")}
</p>
</div>
独立示例在挂载后运行。
此示例有一个单独的上下文,没有 componentSize。一般的图库设置不适用于它:这样,响应式的优先级是可见的,而无需更改站点卡的其余部分。
responsive 和主题阈值
一个没有公共 componentSize 的独立示例:screenXSMax、继承和 inherit:false、优先级 size 以及在更改标记时保存快速跳转草稿。
ResponsivePreview.svelte<script lang="ts"> import { Checkbox, ConfigProvider, Pagination, ruRU } from '@woodger/antd'; let custom = $state(true); let fixed = $state(false); let current = $state(4); let changes = $state(0); const token = $derived( custom ? { screenXSMax: 639, screenSMMin: 640, screenSM: 640, screenSMMax: 899, screenMDMin: 900, screenMD: 900 } : {} ); </script> <style> .example, .scopes { display: grid; gap: 20px; min-width: 0; } .controls { display: flex; flex-wrap: wrap; gap: 12px; } section { min-width: 0; padding: 16px; border-radius: 8px; background: var(--ant-color-bg-container); color: var(--ant-color-text); } h4 { margin: 0 0 12px; } p { margin: 0; } </style> <div class="example"> <div class="controls"> <Checkbox bind:checked={custom}>{("你自己的阈值 分页")}</Checkbox> <Checkbox bind:checked={fixed} >{("固定大小分页大")}</Checkbox> </div> <ConfigProvider locale={ruRU} theme={{ cssVar: { prefix: 'responsive-pager' }, token }}> <div class="scopes"> <section aria-label={("您的阈值分页")}> <h4>{("属于你自己的激流")}</h4> <Pagination class="responsive-pagination-main" aria-label={("具有自己阈值的页面")} responsive size={fixed ? 'large' : undefined} bind:current total={100} showQuickJumper showSizeChanger={false} onChange={() => { changes++; }} /> </section> <ConfigProvider> <section aria-label={("分页阈值继承")}> <h4>{("传统阈值")}</h4> <Pagination class="responsive-pagination-inherited" aria-label={("具有继承阈值的页面")} responsive defaultCurrent={4} total={100} showSizeChanger={false} /> </section> </ConfigProvider> <ConfigProvider theme={{ inherit: false }}> <section aria-label={("重置分页阈值")}> <h4>{("标准阈值")}</h4> <Pagination class="responsive-pagination-reset" aria-label={("具有标准阈值的页面")} responsive defaultCurrent={4} total={100} showSizeChanger={false} /> </section> </ConfigProvider> </div> </ConfigProvider> <output aria-label={("响应式分页状态")} >{("页: ")}{current}{(";变化: ")}{changes}</output> <p> {("自定义 screenXSMax:639px 而不是 575px。嵌套提供程序继承阈值,inherit:false 返回标准阈值。显式大小优先。响应式添加迷你类;它本身的存在不会改变高度,就像 Ant Design 6.6.8 中一样。")} </p> </div>Responsive.svelte<script lang="ts"> import { mount, onMount, unmount } from 'svelte'; import ResponsivePreview from './ResponsivePreview.svelte'; let target: HTMLDivElement; let mounted = $state(false); onMount(() => { const preview = mount(ResponsivePreview, { target, context: new Map() }); mounted = true; return () => { void unmount(preview); }; }); </script> <style> div { min-width: 0; } p { margin: 16px 0 0; } </style> <div bind:this={target} role="group" aria-label={("自适应分页示例")}></div> {#if !mounted}<p>{("独立示例在挂载后运行。")}</p>{/if} <p> {("此示例有一个单独的上下文,没有 componentSize。一般的图库设置不适用于它:这样,响应式的优先级是可见的,而无需更改站点卡的其余部分。")} </p>
API
这些示例是根据当前的 ant.design 页面和已安装包的公共 API 进行检查的。 Props 的完整定义位于 @woodger/antd 中。
| 主题 | 示例或限制 |
|---|---|
| Basic | 常规页面。 |
| Align | 三个对齐。 |
| More | 长列表和短缓冲区。 |
| Changer | 尺寸和处理程序。 |
| Jumper | 输入并执行按钮。 |
| Size | small、medium、large 公共套餐。 |
| Simple mode | 输入数字并 readOnly。 |
| Controlled | 绑定和外部控制。 |
| Total number | showTotal-snippet. |
| Show All | 分享机会。 |
| Prev and next | 你的 itemRender 和 originalElement。 |
| Custom component | components.sizeChanger-snippet. |
| Custom semantic dom styling | 外观和ConfigProvider.pagination。 |
| 属性 | 描述 | 类型 | 默认 |
|---|---|---|---|
prefixCls | 组件及其部件的完整 CSS 前缀。非空本地 prop 优先;空字符串和 undefined 继承ConfigProvider。主题的命名空间是单独设置的。 | string | ConfigProvider.prefixCls + "-pagination" |
total | 记录总数,而不是页数。 | number | 0 |
current | bind:current 将数字绑定到应用程序状态。 | number | defaultCurrent: 1 |
defaultCurrent | 起始编号被读取一次。 | number | 1 |
pageSize | bind:pageSize 将大小绑定到应用程序状态。 | number | defaultPageSize: 10 |
defaultPageSize | 初始大小,读取一次。 | number | 10 |
pageSizeOptions | 标准尺寸选项。 | readonly (number | string)[] | 10, 20, 50, 100 |
showSizeChanger | options 提供带有数值大小和标签的选项。还可以设置 Select 的属性和处理函数。 | boolean | PaginationSizeChangerProps | total > 50 |
totalBoundaryShowSizeChanger | 自动开启尺寸选择的阈值。 | number | 50 |
showQuickJumper | 转换字段输入; goButton 添加确认。 | boolean | { goButton?: PaginationContent } | false |
simple | 当前数量和页数; readOnly 禁用输入。 | boolean | { readOnly?: boolean } | false |
showTotal | 启用边框的当前页面范围。 | Snippet<[total, range]> | — |
showLessItems | 更少的邻居和省略号过渡到三页。 | boolean | false |
showPrevNextJumpers | 通过椭圆显示过渡。 | boolean | true |
hideOnSinglePage | 将整个导航隐藏在一页上。 | boolean | false |
align | 线对齐。 | 'start' | 'center' | 'end' | — |
size | 本地大小优先。 | 'small' | 'medium' | 'large' | 来自配置提供者 |
responsive | XS by theme.token.screenXSMax 仅包含 mini,在 props 或提供程序中没有明确的大小。令牌更新查询无需重新挂载;迷你班本身并不能保证身高的降低。 | boolean | false |
disabled | 禁用控制。 | boolean | 来自配置提供者 |
onChange | 两个论点; Ant Design 6.7.0 的 info.recommendPage 还缺失。 | (page, pageSize) => void | — |
onShowSizeChange | 调整大小时,会在 onChange 之前调用。 | (previousPage, pageSize) => void | — |
itemRender | 它的渲染器将 info.onClick/disabled 绑定到本机控件。 | Snippet<[page, type, originalElement, info]> | — |
components | 可定制尺寸选择。 | { sizeChanger?: Snippet<[PaginationSizeChangerInfo]> } | — |
classNames | root 和项的对象或函数。 | PaginationSemantic | — |
styles | CSS 行 root 和 item;本地值优先于提供者。 | PaginationSemantic | — |
locale | 按钮、字段和 suffix 的名称;支持 Snake_case 别名。 | Partial<PaginationLocale> | 来自配置提供者 |
Semantic DOM
根目录是 nav,具有可访问的名称和 ul 列表。items - 带有本机按钮的 li,活动页面标记为 aria-current。边框和禁用状态按钮确实无法从键盘访问。
Semantic slots: root 指的是导航, item - 到 li 常规页面和过渡。前面的propclass 指的是 ul。 ConfigProvider.pagination 支持 class/style、语义槽、showSizeChanger 及其阈值;本地参数优先。
跳转字段继承Input选项,页面大小选择继承Select:最接近的Form.variant→对应组件设置→通用ConfigProvider.variant→outlined。
itemRender 通过 onClick、disabled、active 和 label 准备好 originalElement 和 info。如果您要替换 originalElement,请将处理程序和可访问名称移至您的本机按钮。
注册令牌
组件令牌的工作原理是 ConfigProvider theme.components.Pagination。该示例更改 items 大小和活动颜色。共享令牌继承该部分的主题。
| 代币 | 目的 |
|---|---|
itemActiveBg | 活动项目的背景。 |
itemActiveBgDisabled | 无法访问的活动项目的背景。 |
itemActiveColor | 活动项目的文本。 |
itemActiveColorDisabled | 无法访问活动文本。 |
itemActiveColorHover | 悬停时的活动文本。 |
itemBg | 正常项目背景。 |
itemInputBg | 领域背景。 |
itemLinkBg | 转换按钮背景。 |
itemSize | 常规物品尺寸。 |
itemSizeLG | 大尺寸物品。 |
itemSizeSM | 小尺寸物品。 |
miniOptionsSizeChangerTop | 偏置 size 变换器为迷你。 |
| 代币 | 当前值 |
|---|---|
colorBgContainer | #ffffff |
colorBgContainerDisabled | rgba(0,0,0,0.04) |
colorBgTextActive | rgba(0,0,0,0.15) |
colorBgTextHover | rgba(0,0,0,0.06) |
colorBorder | #d9d9d9 |
colorBorderDisabled | #d9d9d9 |
colorFillSecondary | rgba(0,0,0,0.06) |
colorFillTertiary | rgba(0,0,0,0.04) |
colorPrimary | #2f54eb |
colorPrimaryBorder | #adc6ff |
colorPrimaryHover | #597ef7 |
colorText | rgba(0,0,0,0.88) |
colorTextDisabled | rgba(0,0,0,0.25) |
colorTextPlaceholder | rgba(0,0,0,0.25) |
borderRadius | 6 |
borderRadiusLG | 8 |
borderRadiusSM | 4 |
controlHeightLG | 40 |
controlOutline | rgba(5,88,255,0.06) |
controlOutlineWidth | 2 |
fontFamily | -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji' |
fontSize | 14 |
fontSizeSM | 12 |
fontWeightStrong | 600 |
lineHeight | 1.5714285714285714 |
lineHeightLG | 1.5 |
lineType | solid |
lineWidth | 1 |
margin | 16 |
marginSM | 12 |
marginXS | 8 |
marginXXS | 4 |
motionDurationMid | 0.2s |
paddingXXS | 4 |
screenLG | 992 |
screenSM | 576 |
sizeLG | 24 |
FAQ
current 与 defaultCurrent 有什么不同?
defaultCurrent 设置初始本地值。 bind:current 允许你从外部控制它; pageSize 的工作原理类似。
支持 recommendPage 面吗?
不。onChange 有两个参数。更改尺寸时保存记录位置是由应用程序设计的。
为什么 responsive 不减少元素?
ConfigProvider 的显式 size 或 componentSize 优先。即使没有它们,responsive 开关也会切换到迷你类,这在固定标准中并不能保证更小的高度。对于固定结果,请使用 size:small。
为什么我手机上的快速通道消失了?
标准 CSS 隐藏宽度最大为 576 像素的字段。主要导航仍然存在。
是否可以更改类前缀?
可以。在 Pagination 上设置 prefixCls,或用 ConfigProvider.prefixCls 设置整个区域的前缀。两种方式都支持主题、设计令牌和各部分的样式。