Ant-design-pro: 🧐[问题]在TSX文件中使用Table,在column字段上产生异常

Created on 26 Mar 2020  ·  5Comments  ·  Source: ant-design/ant-design-pro

🧐 问题描述

不能将类型“

({ title: ReactNode; dataIndex: string; key: string; align: string; width?: undefined; render?: undefined; } | { title: ReactNode; align: string; key: string; width: number; render: (_: any, record: { ...; }) => Element; dataIndex?: undefined; })[]”分配给类型“ColumnsType<{ tenantId: string; }>”。
  不能将类型“{ title: ReactNode; dataIndex: string; key: string; align: string; width?: undefined; render?: undefined; } | { title: ReactNode; align: string; key: string; width: number; render: (_: any, record: { ...; }) => Element; dataIndex?: undefined; }”分配给类型“ColumnGroupType<{ tenantId: string; }> | ColumnType<{ tenantId: string; }>”。
    不能将类型“{ title: React.ReactNode; dataIndex: string; key: string; align: string; width?: undefined; render?: undefined; }”分配给类型“ColumnGroupType<{ tenantId: string; }> | ColumnType<{ tenantId: string; }>”。
      不能将类型“{ title: React.ReactNode; dataIndex: string; key: string; align: string; width?: undefined; render?: undefined; }”分配给类型“ColumnType<{ tenantId: string; }>”。
        属性“align”的类型不兼容。
          不能将类型“string”分配给类型“"center" | "left" | "right" | undefined”。ts(2322)
Table.d.ts(11, 5): The expected type comes from property 'columns' which is declared here on type 'IntrinsicAttributes & Pick<TableProps<{ tenantId: string; }>, "loading" | "children" | "footer" | "style" | "summary" | "title" | "prefixCls" | ... 34 more ... | "sortDirections"> & Partial<...> & Partial<...>

💻 示例代码


image

image

🚑 其他信息

🕵🏻‍♀️ question

Most helpful comment

import { TableProps, ColumnType } from 'antd/es/table';

antd 的有点麻烦

All 5 comments

配置一下类型, ts 现在还不够智能

  const columns: ProColumns<TableListItem>[]

配置一下类型, ts 现在还不够智能

  const columns: ProColumns<TableListItem>[]

我使用的是Antd的Table没有用Pro的Table,不知道Antd的Table应该如何配置.

import { TableProps, ColumnType } from 'antd/es/table';

antd 的有点麻烦

import { TableProps, ColumnType } from 'antd/es/table';

antd 的有点麻烦

感谢

import { TableProps, ColumnType } from 'antd/es/table';

antd 的有点麻烦

整了半天都有点不对,后来我改成ColumnsType了😂😂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

952425340 picture 952425340  ·  3Comments

happier2 picture happier2  ·  3Comments

Yoping picture Yoping  ·  3Comments

skyFi picture skyFi  ·  3Comments

zhuanglong picture zhuanglong  ·  3Comments