努力的欣欣吖 2021-08-17 10:22 采纳率: 100%
浏览 46
已结题

怎么让后台给我的这个数据动态的运用到element ui的树形控件中?不确定有多少下级,我运用进去有问题,显示不出来

怎么让后台给我的这个数据动态的运用到element ui的树形控件中?(** 数据有很多层级,不确定层级,类似选择文件夹的功能**)
最好使用el-tree,我只能显示出一级,其他有问题
我把后端给我的数据贴出来,要树形显示name

{
    "code": 200,
    "message": "",
    "errorMsg": "",
    "total": 0,
    "data": [
        {
            "ofcId": 21,
            "parentId": 0,
            "companyId": 10,
            "name": "2级-你好1",
            "fullName": "2级-你好1",
            "parentPath": "0/",
            "isParent": true,
            "level": 0,
            "isPublic": false,
            "createTime": 1626682259000,
            "updateTime": null,
            "deleted": false,
            "tOssFileClassDTOList": [
                {
                    "ofcId": 26,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": true,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1626689959000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": [
                        {
                            "ofcId": 27,
                            "parentId": 26,
                            "companyId": 10,
                            "name": "4级-111",
                            "fullName": "2级-你好1/3级-123123/4级-111",
                            "parentPath": "0/21/26/",
                            "isParent": false,
                            "level": 2,
                            "isPublic": false,
                            "createTime": 1626690311000,
                            "updateTime": null,
                            "deleted": false,
                            "tOssFileClassDTOList": null,
                            "parent": false,
                            "public": false
                        }
                    ],
                    "parent": true,
                    "public": false
                },
                {
                    "ofcId": 28,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627878410000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                },
                {
                    "ofcId": 29,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627878597000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                },
                {
                    "ofcId": 30,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627880112000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                },
                {
                    "ofcId": 31,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627880316000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                },
                {
                    "ofcId": 32,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627880860000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                },
                {
                    "ofcId": 33,
                    "parentId": 21,
                    "companyId": 10,
                    "name": "3级-123123",
                    "fullName": "2级-你好1/3级-123123",
                    "parentPath": "0/21/",
                    "isParent": false,
                    "level": 1,
                    "isPublic": false,
                    "createTime": 1627880952000,
                    "updateTime": null,
                    "deleted": false,
                    "tOssFileClassDTOList": null,
                    "parent": false,
                    "public": false
                }
            ],
            "parent": true,
            "public": false
        },
        {
            "ofcId": 22,
            "parentId": 0,
            "companyId": 10,
            "name": "2级-阿巴巴",
            "fullName": "2级-阿巴巴",
            "parentPath": "0/",
            "isParent": true,
            "level": 0,
            "isPublic": false,
            "createTime": 1626682268000,
            "updateTime": null,
            "deleted": false,
            "tOssFileClassDTOList": [],
            "parent": true,
            "public": false
        }
    ]
}

谢谢啦

  • 写回答

4条回答 默认 最新

  • gzczzzzzz 2021-08-17 10:30
    关注
    
    <el-tree :data="res.data" :props="{label:'name',children:'tOssFileClassDTOList'}"></el-tree>
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 8月25日
  • 已采纳回答 8月17日
  • 修改了问题 8月17日
  • 修改了问题 8月17日
  • 展开全部

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)