2016-03-31 09:40:55 +08:00
---
2016-11-22 10:11:12 +08:00
order: 17
2016-08-15 07:54:01 +08:00
title:
en-US: Fixed Header
zh-CN: 固定表头
2016-03-31 09:40:55 +08:00
---
2016-01-24 15:39:34 +08:00
2016-08-15 08:07:03 +08:00
## zh-CN
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
方便一页内展示大量数据。
2016-08-15 07:54:01 +08:00
2019-04-14 14:24:06 +08:00
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。如果指定 `width` 不生效,请尝试建议留一列不设宽度以适应弹性布局,或者检查是否有[超长连续字段破坏布局](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241)。
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
## en-US
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
Display large amounts of data in scrollable view.
2016-01-24 15:39:34 +08:00
2019-04-14 14:24:06 +08:00
> Specify width of columns if header and cell do not align properly. If specified width is not working, please try to leave one column at least without width to fit fluid layout, or make sure no [long word to break table layout](https://github.com/ant-design/ant-design/issues/13825#issuecomment-449889241).
2016-03-06 22:44:58 +08:00
2019-05-07 14:57:32 +08:00
```jsx
2016-01-24 15:39:34 +08:00
import { Table } from 'antd';
2019-05-07 14:57:32 +08:00
const columns = [
{
title: 'Name',
dataIndex: 'name',
width: 150,
},
{
title: 'Age',
dataIndex: 'age',
width: 150,
},
{
title: 'Address',
dataIndex: 'address',
},
];
2016-01-24 15:39:34 +08:00
const data = [];
for (let i = 0; i < 100 ; i + + ) {
data.push({
key: i,
2016-10-02 08:47:42 +08:00
name: `Edward King ${i}` ,
2016-01-24 15:39:34 +08:00
age: 32,
2016-10-02 08:47:42 +08:00
address: `London, Park Lane no. ${i}` ,
2016-01-24 15:39:34 +08:00
});
}
ReactDOM.render(
2018-06-27 15:55:04 +08:00
< Table columns = {columns} dataSource = {data} pagination = {{ pageSize: 50 } } scroll = {{ y: 240 } } / > ,
2019-05-07 14:57:32 +08:00
mountNode,
2018-11-28 15:00:03 +08:00
);
2019-05-07 14:57:32 +08:00
```