vue element 生成无线级左侧菜单的实现代码
前端  /  管理员 发布于 5年前   368
首先来总结element ui 官方文档的左侧菜单结构,带有el-submenu为子级节点,el-menu-item表示没有下级。当然,菜单不能写死,因为菜单也许不止两级,所以我们需要递归来实现。根据当前节点是否有下级去判断,如果有下级,则继续调用子级,直到没有下级为止,下面我贴上左侧菜单所有的代码:
请求数据格式
[ { name: "首页", id: -1, icon: "el-icon-picture-outline-round", url: "/index", children: [] }, { name: "按钮", id: 20, icon: "el-icon-message-solid", url: "/button", children: [] }, { name: "测试1", id: 1, icon: "el-icon-s-claim", url: "", children: [ { id: 4, parentid: 1, name: "测试1-1", icon: "el-icon-chat-dot-round", url: "", children: [ { id: 8, parentid: 1, name: "测试1-1-1", icon: "el-icon-cloudy", url: "/test", children: [] }, { id: 9, parentid: 1, name: "测试1-1-2", icon: "el-icon-files", url: "/test1", children: [] } ] }, { id: 5, parentid: 1, name: "测试1-2", icon: "el-icon-shopping-cart-1", url: "/test3", children: [] } ] }, { name: "测试2", id: 2, icon: "el-icon-menu", url: "", children: [ { id: 6, parentid: 2, name: "测试2-1", icon: "el-icon-folder-checked", url: "", children: [] }, { id: 7, parentid: 2, name: "测试2-2", icon: "el-icon-folder-remove", url: "", children: [] } ] }, { name: "测试3", id: 3, icon: "el-icon-monitor", url: "", children: [] } ]menu.vue
Top
- 相关文章
- 使用 Alpine.js 排序插件对元素进行排序(0个评论)
- 在js中使用jszip + file-saver实现批量下载OSS文件功能示例(0个评论)
- 在vue中实现父页面按钮显示子组件中的el-dialog效果(0个评论)
- 使用mock-server实现模拟接口对接流程步骤(0个评论)
- vue项目打包程序实现把项目打包成一个exe可执行程序(0个评论)
- 近期文章
- OpenAI GPT-5.5正式发布:更会编程和使用计算机的最强模型!(0个评论)
- opencode AI智能体自主规划开发游戏:王者荣耀模拟战游戏初体验!英雄角色开发中...(0个评论)
- opencode AI智能体自主规划开发游戏:王者荣耀模拟战游戏初体验!(0个评论)
- opencode + Oh-my-openagent,我的第一个免费的ai编程智能体管家:Sisyphus(0个评论)
- Google AI Studio升级全栈 vibe coding体验,可直接构建带登录和数据库的应用(0个评论)
- Apifox桌面端被曝遭供应链投毒:CDN 脚本被篡改,窃取 SSH 密钥与 Git 凭证(0个评论)
- 在go语言中实现字符串可逆性压缩及解压缩功能(0个评论)
- 使用go + gin + jwt + qrcode实现网站生成登录二维码在app中扫码登录功能(0个评论)
- 在windows10中升级go版本至1.24后LiteIDE的Ctrl+左击无法跳转问题解决方案(0个评论)
- 智能合约Solidity学习CryptoZombie第四课:僵尸作战系统(0个评论)
- 近期评论
test1 在
opencode + Oh-my-openagent,我的第一个免费的ai编程智能体管家:Sisyphus中评论 test..122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..Zita 在
Google AI Studio升级全栈 vibe coding体验,可直接构建带登录和数据库的应用中评论 111222..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号
