2020-04-24 12:17:42 +08:00
|
|
|
---
|
|
|
|
order: 31
|
|
|
|
title:
|
|
|
|
zh-CN: 响应式
|
|
|
|
en-US: Responsive
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
响应式配置列的展示。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Responsive columns.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2020-04-24 12:17:42 +08:00
|
|
|
import { Table } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import type { ColumnsType } from 'antd/lib/table';
|
2022-05-23 14:37:16 +08:00
|
|
|
import React from 'react';
|
2020-04-24 12:17:42 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
interface DataType {
|
|
|
|
key: React.Key;
|
|
|
|
name: string;
|
|
|
|
age: number;
|
|
|
|
address: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const columns: ColumnsType<DataType> = [
|
2020-04-24 12:17:42 +08:00
|
|
|
{
|
|
|
|
title: 'Name (all screens)',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
render: text => <a>{text}</a>,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age (medium screen or bigger)',
|
|
|
|
dataIndex: 'age',
|
|
|
|
key: 'age',
|
|
|
|
responsive: ['md'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Address (large screen or bigger)',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address',
|
|
|
|
responsive: ['lg'],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const data: DataType[] = [
|
2020-04-24 12:17:42 +08:00
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
name: 'John Brown',
|
|
|
|
age: 32,
|
|
|
|
address: 'New York No. 1 Lake Park',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => <Table columns={columns} dataSource={data} />;
|
|
|
|
|
|
|
|
export default App;
|
2020-04-24 12:17:42 +08:00
|
|
|
```
|