Ant design 表格报错:TypeError: Cannot read property 'children' of undefined
这个报错表明表格中给的columns
或者data
有问题,比如columns
为空,或者data
里面有格式不对的数据(某一行数据为undefined
)
我排除了一下代码报错的原因,就是因为有一行数据为undefined
。。所以报错了。在对后端返回的数据进行格式化的时候,一定要注意判空处理,这样可以省略很多不必要的麻烦~
部分报错截图
TypeError: Cannot read property 'children' of undefined
(anonymous function)
C:/Users/WebstormProjects/bond/node_modules/rc-table/es/ExpandableTable.js:137
134 | children = _props2.children;
135 |
136 | var needIndentSpaced = data.some(function (record) {
> 137 | return record[childrenColumnName];
138 | });
139 |
140 | return children({
View compiled
ExpandableTable.render
C:/Users/WebstormProjects/bond/node_modules/rc-table/es/ExpandableTable.js:136
133 | childrenColumnName = _props2.childrenColumnName,
134 | children = _props2.children;
135 |
> 136 | var needIndentSpaced = data.some(function (record) {
137 | return record[childrenColumnName];
138 | });
139 |