需求:可以展开/折叠的效果的列表
image.png
image.png
问题
展开id为2的的行时,发现
const expandedRowRender = (record,index) => { };
执行了3次
[{
"id": 2,
"name": "测试新增789",
"title": "测试标题",
"icons": "测试图标",
"path": "测试路径",
"parentId": 0,
"sort": 0,
"type": 1,
"children": [
{
"id": 28,
"name": "测试新增789",
"title": "测试标题",
"icons": "测试图标",
"path": "1",
"parentId": 2,
"sort": 0,
"type": 1,
},
{
"id": 29,
"name": "测试新增789",
"title": "测试标题",
"icons": "测试图标",
"path": "测试路径",
"parentId": 2,
"sort": 0,
"type": 1,
}
]
},
{
"id": 31,
"name": "新增222",
"title": "标题",
"icons": "图标",
"path": "路径",
"parentId": 0,
"sort": 0,
"type": 1,
"children": []
}]
原因
json数据中children字段和Table组件的expandedRowRender里面的底层代码相冲突,导致多次执行
const expandedRowRender = (record,index) => { };
网友评论