mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-19 11:58:41 +08:00
46 lines
811 B
TypeScript
46 lines
811 B
TypeScript
import React from 'react';
|
|
import { Table } from 'antd';
|
|
import type { TableColumnsType } from 'antd';
|
|
|
|
interface DataType {
|
|
key: React.Key;
|
|
name: string;
|
|
age: number;
|
|
address: string;
|
|
}
|
|
|
|
const columns: TableColumnsType<DataType> = [
|
|
{
|
|
title: 'Name',
|
|
dataIndex: 'name',
|
|
},
|
|
{
|
|
title: 'Age',
|
|
dataIndex: 'age',
|
|
},
|
|
{
|
|
title: 'Address',
|
|
dataIndex: 'address',
|
|
},
|
|
];
|
|
|
|
const dataSource = Array.from({ length: 200 }).map<DataType>((_, key) => ({
|
|
key,
|
|
name: 'Sample Name',
|
|
age: 30 + (key % 5),
|
|
address: `Sample Address ${key}`,
|
|
}));
|
|
|
|
const App: React.FC = () => (
|
|
<div style={{ width: 300 }}>
|
|
<Table<DataType>
|
|
columns={columns}
|
|
dataSource={dataSource}
|
|
size="small"
|
|
pagination={{ defaultCurrent: 13 }}
|
|
/>
|
|
</div>
|
|
);
|
|
|
|
export default App;
|