2015-07-09 20:29:26 +08:00
|
|
|
# 分页
|
|
|
|
|
2015-10-09 17:14:09 +08:00
|
|
|
- order: 5
|
2015-07-09 20:29:26 +08:00
|
|
|
|
|
|
|
数据项较多时显示分页。
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Table } from 'antd';
|
2015-07-14 15:35:17 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const columns = [{
|
2015-07-14 15:35:17 +08:00
|
|
|
title: '姓名',
|
2015-07-15 10:47:47 +08:00
|
|
|
dataIndex: 'name',
|
|
|
|
render: function(text) {
|
2015-11-25 17:35:49 +08:00
|
|
|
return <a href="#">{text}</a>;
|
2015-07-15 10:47:47 +08:00
|
|
|
}
|
2015-07-14 15:35:17 +08:00
|
|
|
}, {
|
|
|
|
title: '年龄',
|
|
|
|
dataIndex: 'age'
|
|
|
|
}, {
|
|
|
|
title: '住址',
|
2015-07-15 10:47:47 +08:00
|
|
|
dataIndex: 'address'
|
2015-07-14 15:35:17 +08:00
|
|
|
}];
|
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const data = [];
|
2015-11-25 17:35:49 +08:00
|
|
|
for (let i = 0; i < 46; i++) {
|
2015-07-14 15:35:17 +08:00
|
|
|
data.push({
|
2015-08-28 15:22:09 +08:00
|
|
|
key: i,
|
2015-07-14 15:35:17 +08:00
|
|
|
name: '李大嘴' + i,
|
|
|
|
age: 32,
|
2015-07-14 16:34:26 +08:00
|
|
|
address: '西湖区湖底公园' + i + '号'
|
2015-07-14 15:35:17 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const pagination = {
|
2015-07-28 12:26:54 +08:00
|
|
|
total: data.length,
|
2015-09-23 14:28:08 +08:00
|
|
|
current: 2,
|
|
|
|
showSizeChanger: true
|
2015-07-14 15:35:17 +08:00
|
|
|
};
|
|
|
|
|
2015-10-20 16:47:55 +08:00
|
|
|
ReactDOM.render(<Table columns={columns} dataSource={data} pagination={pagination} />
|
2015-07-14 15:35:17 +08:00
|
|
|
, document.getElementById('components-table-demo-paging'));
|
2015-07-09 20:29:26 +08:00
|
|
|
````
|