mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
14a1e6bd51
* feat: tsconfig enable strict * feat: add no-explicit-any * feat: strict * feat: as THEME * feat: 优化 keys 类型写法 * feat: demo remove any * feat: as number * feat: this any * feat: add eslint * feat: cascader * feat: props any * feat: remove any * feat: remove any * feat: any 提示错误 * feat: remove any * feat: add eslint * feat: 允许 T = any 存在 * feat: color funciton * feat: 恢复 lint * feat: merge master * feat: as ReactElement * feat: type
127 lines
2.3 KiB
TypeScript
127 lines
2.3 KiB
TypeScript
import React from 'react';
|
|
import { Table } from 'antd';
|
|
import type { TableColumnsType } from 'antd';
|
|
|
|
interface DataType {
|
|
key: React.Key;
|
|
name: string;
|
|
age: number;
|
|
street: string;
|
|
building: string;
|
|
number: number;
|
|
companyAddress: string;
|
|
companyName: string;
|
|
gender: string;
|
|
}
|
|
|
|
const columns: TableColumnsType<DataType> = [
|
|
{
|
|
title: 'Name',
|
|
dataIndex: 'name',
|
|
key: 'name',
|
|
width: 100,
|
|
fixed: 'left',
|
|
filters: [
|
|
{
|
|
text: 'Joe',
|
|
value: 'Joe',
|
|
},
|
|
{
|
|
text: 'John',
|
|
value: 'John',
|
|
},
|
|
],
|
|
onFilter: (value, record) => record.name.indexOf(value as string) === 0,
|
|
},
|
|
{
|
|
title: 'Other',
|
|
children: [
|
|
{
|
|
title: 'Age',
|
|
dataIndex: 'age',
|
|
key: 'age',
|
|
width: 150,
|
|
sorter: (a, b) => a.age - b.age,
|
|
},
|
|
{
|
|
title: 'Address',
|
|
children: [
|
|
{
|
|
title: 'Street',
|
|
dataIndex: 'street',
|
|
key: 'street',
|
|
width: 150,
|
|
},
|
|
{
|
|
title: 'Block',
|
|
children: [
|
|
{
|
|
title: 'Building',
|
|
dataIndex: 'building',
|
|
key: 'building',
|
|
width: 100,
|
|
},
|
|
{
|
|
title: 'Door No.',
|
|
dataIndex: 'number',
|
|
key: 'number',
|
|
width: 100,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: 'Company',
|
|
children: [
|
|
{
|
|
title: 'Company Address',
|
|
dataIndex: 'companyAddress',
|
|
key: 'companyAddress',
|
|
width: 200,
|
|
},
|
|
{
|
|
title: 'Company Name',
|
|
dataIndex: 'companyName',
|
|
key: 'companyName',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: 'Gender',
|
|
dataIndex: 'gender',
|
|
key: 'gender',
|
|
width: 80,
|
|
fixed: 'right',
|
|
},
|
|
];
|
|
|
|
const data: DataType[] = [];
|
|
for (let i = 0; i < 100; i++) {
|
|
data.push({
|
|
key: i,
|
|
name: 'John Brown',
|
|
age: i + 1,
|
|
street: 'Lake Park',
|
|
building: 'C',
|
|
number: 2035,
|
|
companyAddress: 'Lake Street 42',
|
|
companyName: 'SoftLake Co',
|
|
gender: 'M',
|
|
});
|
|
}
|
|
|
|
const App: React.FC = () => (
|
|
<Table
|
|
columns={columns}
|
|
dataSource={data}
|
|
bordered
|
|
size="middle"
|
|
scroll={{ x: 'calc(700px + 50%)', y: 240 }}
|
|
/>
|
|
);
|
|
|
|
export default App;
|