我是靠谱客的博主 眯眯眼航空,这篇文章主要介绍ant design table 报错:Component definition is missing display name,现在分享给大家,希望可以做个参考。
环境:
1.react: 16
2.ant: 3.15
问题:table在webpack用了eslint情况下,会报错:Component definition is missing display name. 把eslint注释掉又不报错了
代码如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51class Search extends Component { // do something } // 说明一下,不继承Search类是不会报错的 class SearchAction extends Search { constructor() { this.state = { fields: [ { title: '客户类型', dataIndex: 'customer_type', key: 'show_customer_type' }, { title: '申请人/申请日期', dataIndex: 'last_save_name', key: 'last_save_name', render: (text, record) => ( <Fragment> <div>{record.last_save_name || '无'}</div> <div>{record.last_save_time || '无'}</div> </Fragment> ) } ] }; } render{ const props = { dataSource: this.state.fields, className: 'table-cus' }; return ( <div> <Table {...props}> {this.state.fields.map(elt => ( <Column title={elt.title} key={elt.key} dataIndex={elt.dataIndex} render={elt.render || (text => text)} /> )} </Table> </div> ); }; }
目前我也不知道是什么原因,因为在table里,text和record两个参数是存在的。
可能是因为ant没做好兼容吧
最后我的解决办法是:直接用eslint-disable来注释掉报错的代码 (不得已而为之 = =)
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14/*eslint-disable*/ { title: '申请人/申请日期', dataIndex: 'last_save_name', key: 'last_save_name', render: (text, record) => ( <Fragment> <div>{record.last_save_name || '无'}</div> <div>{record.last_save_time || '无'}</div> </Fragment> ) } /*eslint-disable*/
最后
以上就是眯眯眼航空最近收集整理的关于ant design table 报错:Component definition is missing display name的全部内容,更多相关ant内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复