ant-design/components/pagination/demo/controlled.md

34 lines
545 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 8
2016-07-29 10:15:31 +08:00
title:
zh-CN: 受控
en-US: Controlled
2016-03-31 09:40:55 +08:00
---
2015-11-26 12:17:19 +08:00
2016-07-29 10:15:31 +08:00
## zh-CN
2015-11-26 17:15:18 +08:00
受控制的页码。
2015-11-26 12:17:19 +08:00
2016-07-29 10:15:31 +08:00
## en-US
Controlled page number.
```tsx
import type { PaginationProps } from 'antd';
2015-11-26 12:17:19 +08:00
import { Pagination } from 'antd';
2022-05-23 14:37:16 +08:00
import React, { useState } from 'react';
2015-11-26 12:17:19 +08:00
const App: React.FC = () => {
const [current, setCurrent] = useState(3);
2018-06-27 15:55:04 +08:00
const onChange: PaginationProps['onChange'] = page => {
2015-11-26 17:15:18 +08:00
console.log(page);
setCurrent(page);
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
return <Pagination current={current} onChange={onChange} total={50} />;
};
2015-11-26 17:15:18 +08:00
export default App;
2019-05-07 14:57:32 +08:00
```