New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table组件使用fixed属性报错 #3772
Comments
好像是 typescript 的正常行为。 |
。。。这么变态 |
type Foo = boolean | 'left' | 'right';
let foo = 'right';
const bar: Foo = foo; 这里 |
我这边不会提示这个错误 |
@infeng 你 typescript 是什么版本? |
2.0.8 |
@infeng 我用 2.0.8 也有这个错误。。。 |
原来我看错了,也是有这个错误。。。 |
import { TableColumnConfig } from 'antd/lib/table/Table';
let columns: TableColumnConfig[] = [{
title: 'name',
fixed: 'right',
}]; 这样写可以省点功夫,不用每个fixed都写 |
@infeng import React, { Component } from 'react';
import { Table } from 'antd';
import { TableColumnConfig } from 'antd/lib/table/Table';
interface Person {
name: string;
}
const columns: TableColumnConfig<Person>[] = [{
title: 'Name',
dataIndex: 'name',
fixed: 'right',
}];
const data: Person[] = [{
name: 'Jack',
}];
class PersonTable extends Table<Person> {}
class App extends Component<null, null> {
render() {
return (
<PersonTable columns={columns} dataSource={data} />
)
}
} |
对,最新版的是要加generic,我忘记我用的antd还是2.1.0,还没有加上generic |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
发生问题的环境是:
按照官网提供的示例代码
编译过程报错
Type 'string' is not assignable to type 'boolean | "left" | "right"'.
除非写成
fixed:'right' as 'right'
期待的结果是:
怎么能像官网一样的写法不报错
The text was updated successfully, but these errors were encountered: