mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
docs(table): generic type arguments in jsx elements demo
This commit is contained in:
parent
5204b45e01
commit
0760cb7ff7
@ -176,7 +176,7 @@ Properties for row selection.
|
||||
|
||||
## Using in TypeScript
|
||||
|
||||
```jsx
|
||||
```tsx
|
||||
import { Table } from 'antd';
|
||||
import { ColumnProps } from 'antd/lib/table';
|
||||
|
||||
@ -206,6 +206,13 @@ class NameColumn extends Table.Column<IUser> {}
|
||||
<UserTable dataSource={data}>
|
||||
<NameColumn key="name" title="Name" dataIndex="name" />
|
||||
</UserTable>
|
||||
|
||||
// after TypeScript 2.9 can write like this
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#generic-type-arguments-in-jsx-elements
|
||||
<Table<IUser> columns={columns} dataSource={data} />
|
||||
<Table<IUser> dataSource={data}>
|
||||
<Table.Column<IUser> key="name" title="Name" dataIndex="name" />
|
||||
</Table>
|
||||
```
|
||||
|
||||
## Note
|
||||
|
@ -181,7 +181,7 @@ const columns = [{
|
||||
|
||||
## 在 TypeScript 中使用
|
||||
|
||||
```jsx
|
||||
```tsx
|
||||
import { Table } from 'antd';
|
||||
import { ColumnProps } from 'antd/lib/table';
|
||||
|
||||
@ -210,6 +210,14 @@ class NameColumn extends Table.Column<IUser> {}
|
||||
<UserTable dataSource={data}>
|
||||
<NameColumn key="name" title="Name" dataIndex="name" />
|
||||
</UserTable>
|
||||
|
||||
// TypeScript 2.9 之后也可以这样写
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#generic-type-arguments-in-jsx-elements
|
||||
<Table<IUser> columns={columns} dataSource={data} />
|
||||
<Table<IUser> dataSource={data}>
|
||||
<Table.Column<IUser> key="name" title="Name" dataIndex="name" />
|
||||
</Table>
|
||||
|
||||
```
|
||||
|
||||
## 注意
|
||||
|
Loading…
Reference in New Issue
Block a user