news 2026/7/8 4:02:27

Element Plus-el-table树形数据

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Element Plus-el-table树形数据

概念:支持树类型的数据的显示。 当 row 中包含children字段时,被视为树形数据。 渲染嵌套数据需要 prop 的row-key

要实现这样的效果,要注意:

<el-table :data="treeData" <!-- 传入你的数据 --> row-key="id" <!-- ① 每行的唯一标识 --> :tree-props="{ children: 'children' }" <!-- ② 子节点在哪个字段 --> >
  • row-key="id":告诉 el-table 用每个节点的id作为唯一 key 来追踪展开/折叠状态
  • tree-props="{ children: 'children' }":告诉 el-table 子数据在children字段里找
  • 数据正好是{ id: 2, children: [{ id: 7, ... }] }这种结构

示例数据结构:

[{"id":2,"parentId":null,"name":"用户管理","path":"/user","icon":"User","permission":"user","type":"menu","visible":true,"sort":2,"component":null,"createTime":"1782801420445","updateTime":"1782813495701","children":[{"id":7,"parentId":2,"name":"管理员","path":"/user/admin","icon":null,"permission":"user:admin","type":"menu","visible":true,"sort":1,"component":"@/views/user/AdminUserList.vue","createTime":"1782801420964","updateTime":"1782801420964","children":[]},{"id":8,"parentId":2,"name":"B端用户","path":"/user/b","icon":null,"permission":"user:b","type":"menu","visible":true,"sort":2,"component":"@/views/user/BUserList.vue","createTime":"1782801421127","updateTime":"1782801421127","children":[]}]},

{"id":23,"parentId":null,"name":"系统管理","path":"/system","icon":"Setting","permission":"system","type":"menu","visible":true,"sort":8,"component":null,"createTime":"1782802591777","updateTime":"1782802591777","children":[{"id":24,"parentId":23,"name":"菜单管理","path":"/system/menu","icon":null,"permission":"system:menu","type":"menu","visible":true,"sort":1,"component":"@/views/system/MenuList.vue","createTime":"1782802592547","updateTime":"1782802592547","children":[]},{"id":25,"parentId":23,"name":"角色管理","path":"/system/role","icon":null,"permission":"system:role","type":"menu","visible":true,"sort":2,"component":"@/views/system/RoleList.vue","createTime":"1782802592742","updateTime":"1782893277192","children":[]}]}]

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/8 4:02:12

美容院清洁补水仪器怎么选?

美容院清洁补水仪器不能只看“小气泡”这个名称&#xff0c;而要看设备能不能支撑完整清洁补水项目。普通小气泡更偏基础清洁&#xff0c;奈石 G63 漩热之星则属于大气泡综合仪和热气泡清洁补水设备&#xff0c;主打 360旋转热气泡笔、9 个探头、水循环加热和十档恒温&#xff…

作者头像 李华
网站建设 2026/7/8 4:02:04

效率直接起飞 2026 最新降AIGC网站测评与推荐

2026年真正好用的AI论文降重与改写工具&#xff0c;核心看降重效果、去AI味、格式保留、学术适配四大指标。综合实测&#xff0c;千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队&#xff0c;覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 …

作者头像 李华
网站建设 2026/7/8 4:01:27

废水监测质量控制涉及的阶段

在废水监测过程中质量控制是很重要的&#xff0c;其中涉及多个任务&#xff0c;再给出废水分析过程中质量控制的应对方法。至今为止&#xff0c;已经有很多的城市都建立了废水监测机构&#xff0c;目的当然是针对城市各产生排出的污水 处理完成后&#xff0c;进行实时监测&…

作者头像 李华
网站建设 2026/7/8 3:59:24

LLM驱动的参数自适应控制器:结构化剪枝实现嵌入式轻量化落地

1. 项目概述&#xff1a;当大语言模型开始“调教”机器人控制器你有没有试过让一个二连杆机械臂在负载突变时依然稳稳停在目标位置&#xff1f;或者让ROS导航中的差速轮式机器人&#xff0c;在湿滑地面急转弯时不打滑、不甩尾&#xff1f;传统控制工程师的日常&#xff0c;就是…

作者头像 李华
网站建设 2026/7/8 3:58:36

How evals drive the next chapter in AI for businesses

Over one million businesses⁠ around the world are leveraging AI to drive greater efficiency and value creation. But some organizations have struggled to get the results they are expecting. What is causing the gap? At OpenAI we are leveraging AI internal…

作者头像 李华
网站建设 2026/7/8 3:56:18

STM32L496AG与MAX11108A构建高精度低功耗数据采集系统

1. 项目背景与核心价值在工业测量、医疗设备和消费电子等领域&#xff0c;模拟信号到数字信号的转换&#xff08;ADC&#xff09;是嵌入式系统设计中最基础也最关键的环节之一。MAX11108A作为一款16位、8通道、低功耗SAR型ADC&#xff0c;与STM32L496AG这款基于Cortex-M4内核的…

作者头像 李华