antd 表格用fixed:“left”在typescript中报错

[ts]
Type '{ pagination: { total: number; pageSize: number; defaultPageSize: number; showSizeChanger: true; ...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes> & Readonly<{ children?: ReactNode; }> &...'.
Type '{ pagination: { total: number; pageSize: number; defaultPageSize: number; showSizeChanger: true; ...' is not assignable to type 'Readonly>'.
Types of property 'columns' are incompatible.
Type '({ title: string; dataIndex: string; key: string; fixed: boolean; width: number; } | { title: str...' is not assignable to type 'ColumnProps<{}>[]'.
Type '{ title: string; dataIndex: string; key: string; fixed: boolean; width: number; } | { title: stri...' is not assignable to type 'ColumnProps<{}>'.
Type '{ title: string; dataindex: string; fixed: string; key: string; render: (text: any, record: any) ...' is not assignable to type 'ColumnProps<{}>'.
Types of property 'fixed' are incompatible.
Type 'string' is not assignable to type 'boolean | "left" | "right"'.
(JSX attribute) bordered: true

 

 

解决方案:

1.columns=[{fixed:'left'} as ColumnProps]

2.columns: [

      {
        title: 'xxx',
        dataIndex: 'xxx',
        fixed: 'left' as 'left', // cast fixed
      },
]

你可能感兴趣的:(web前端)