分隔长列表,每次只加载一个页面。
规则
代码演示
基本
基本的分页器。
import { Pagination, Icon } from 'antd-mobile';
const locale = {
prevText: 'Prev',
nextText: 'Next',
};
const App = () => (
<div className="pagination-container" >
<p className="sub-title">Button with text</p>
<Pagination total={5} current={1} locale={locale} />
<p className="sub-title">Button with text and icon</p>
<Pagination total={5}
className="custom-pagination-with-icon"
current={1}
locale={{
prevText: (<span className="arrow-align"><Icon type="left" />上一步</span>),
nextText: (<span className="arrow-align">下一步<Icon type="right" /></span>),
}}
/>
<p className="sub-title">Hide number</p>
<Pagination simple total={5} current={1} locale={locale} />
<p className="sub-title">Show number only</p>
<Pagination mode="number" total={5} current={3} />
<p className="sub-title">Point Style</p>
<Pagination mode="pointer" total={5} current={2} style={{ marginBottom: '0.32rem' }} />
</div>
);
ReactDOM.render(<App />, mountNode);
.pagination-container {
margin: 0 0.3rem;
}
.custom-pagination-with-icon .am-pagination-wrap-btn-prev .am-button-inline{
padding-left: 0;
padding-right: 0.2rem;
}
.custom-pagination-with-icon .am-pagination-wrap-btn-next .am-button-inline{
padding-left: 0.2rem;
padding-right: 0;
}
.arrow-align {
display: flex;
align-items: center;
}
.sub-title {
color: #888;
font-size: .28rem;
padding: 30px 0 18px 0;
}
API
适用平台:WEB、React-Native
属性 | 说明 | 类型 | 默认值 |
---|
mode | 形态,可选button ,number ,pointer | string | button |
current | 当前索引(注意索引是从0开始计数的) | number | 无 |
total | 数据总数 | number | 0 |
simple | 是否隐藏数值 | boolean | false |
disabled | 禁用状态 | boolean | false |
locale | 国际化, 可以覆盖全局LocaleProvider 的配置 | Object:{prevText, nextText} | 无 |
onChange | change 事件触发的回调函数 | (e: Object): void | 无 |