2021-04-08 20:47:19 +08:00
|
|
|
---
|
|
|
|
order: 11.5
|
|
|
|
title:
|
|
|
|
en-US: size
|
|
|
|
zh-CN: 紧凑型
|
|
|
|
debug: true
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
两种紧凑型的列表,小型列表只用于对话框内。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
There are two compacted table sizes: `middle` and `small`. The `small` size is used in Modals only.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2021-04-08 20:47:19 +08:00
|
|
|
import { Table } from 'antd';
|
2022-07-04 22:09:54 +08:00
|
|
|
import type { ColumnsType } from 'antd/es/table';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2021-04-08 20:47:19 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
interface DataType {
|
|
|
|
key: React.Key;
|
|
|
|
name: string;
|
|
|
|
age: number;
|
|
|
|
address: string;
|
|
|
|
}
|
2021-04-08 20:47:19 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const columns: ColumnsType<DataType> = [
|
2021-04-08 20:47:19 +08:00
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Address',
|
|
|
|
dataIndex: 'address',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const data: DataType[] = [];
|
2021-04-08 20:47:19 +08:00
|
|
|
|
|
|
|
for (let i = 0; i < 200; i += 1) {
|
|
|
|
data.push({
|
|
|
|
key: i,
|
|
|
|
name: 'Sample Name',
|
|
|
|
age: 30 + (i % 5),
|
|
|
|
address: `Sample Address ${i}`,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2021-04-08 20:47:19 +08:00
|
|
|
<div style={{ width: 300 }}>
|
|
|
|
<Table columns={columns} dataSource={data} size="small" pagination={{ defaultCurrent: 13 }} />
|
2022-04-03 23:27:45 +08:00
|
|
|
</div>
|
2021-04-08 20:47:19 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2021-04-08 20:47:19 +08:00
|
|
|
```
|