美文网首页
React Table组件的expandedRowRender展

React Table组件的expandedRowRender展

作者: CoderZb | 来源:发表于2021-08-19 11:21 被阅读0次

    需求:可以展开/折叠的效果的列表


    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) => { };

    相关文章

      网友评论

          本文标题:React Table组件的expandedRowRender展

          本文链接:https://www.haomeiwen.com/subject/fivobltx.html