努力的欣欣吖 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 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能
  • ¥15 空间转录组CRAD遇到问题
  • ¥20 materialstudio计算氢键脚本问题