docs(table): generic type arguments in jsx elements demo

This commit is contained in:
muzea 2018-11-09 18:04:47 +08:00 committed by 偏右
parent 5204b45e01
commit 0760cb7ff7
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -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>
```
## 注意