当前位置: 首页 > news >正文

Vue3后台管理系统Element-plus_侧边栏制作_无限递归

在home.view中添加代码

<template><div><div class="common-layout"><el-container><el-header class="common-header flex-float"><div class="flex"><img class="logo" src="../assets/logo.png" alt="" /><h1 class="title">商铺后台管理系统</h1></div><el-button type="danger">退出</el-button></el-header><el-container><!-- 侧边栏 --><el-aside class="common-aside" width="200px"><!-- 菜单 --><el-menu background-color="none" text-color="#fff" :router="true"><testItem v-for="menu in menuList" :menu="menu" :key="menu.id" :index="menu.id+''"></testItem></el-menu></el-aside><el-main><router-view></router-view></el-main></el-container></el-container></div></div>
</template>
<script setup>
import { reactive } from 'vue'
let menuList = reactive([{authname: "随便管理",id: 1,children: []},{authname: "用户管理",id: 2,children: [{authname: "二级用户1",id: 12,children: []},{authname: "二级用户2",id: 13,children: [{id: 14,authname: "三级用户1"}]}]},{authname: "订单管理",id: 3,children: [{authname: "二级订单1",id: 15,children: []},{authname: "二级订单2",id: 16,children: [{id: 17,authname: "三级订单1",children:[{id:18,authname:"四级",children:[{id:20,authname:"五级",children:[]}]}]}]}]}
])
</script>
<style >
.el-container {height: 100vh;overflow: hidden;
}.common-header {background: rgb(63 67 72);
}.common-aside {background: rgb(48, 55, 65);
}.logo {width: 60px;
}.title {color: #fff;
}
</style>

 2 创建一个全局组件

<template lang=""><el-menu-item :index="menu.id+''"  v-if="!menu.children || menu.children.length == 0" ><image src="../assets/logo.png" style="width:30px;height:30px;"/><span>{{ menu.authname }}</span></el-menu-item><el-sub-menu v-else ><template #title><image src="../assets/logo.png" style="width:30px;height:30px;"/><span>{{ menu.authname }}</span></template><!-- 二级菜单 --><el-menu-item-group v-if=" menu.children&& menu.children.length>0"><testItem  v-for="item in menu.children" :key="item.id" :index="item.id+''" :menu="item"></testItem></el-menu-item-group><testItem v-else  v-for="item in menu.children" :key="item.id" :index="item.id+''" :menu="item"></testItem></el-sub-menu></template><script>export default {name: 'testItem',props: {menu: Object}
}
</script><style lang=""></style>

 效果如图

http://www.lryc.cn/news/164706.html

相关文章:

  • PCIe基础概念
  • GE IS220PVIBH1A 336A4940CSP16 数字输入模块
  • 比特币与火人节
  • Nginx 中 location 和 proxy_pass 斜杠/ 问题
  • 【Spring】开发框架Spring核心技术含Resource接口详细讲解
  • 【随想】每日两题Day.5 (实则一题)
  • 【LeetCode刷题笔记】动态规划 — 70.爬楼梯
  • 2024腾讯校招后端面试真题汇总及其解答(三)
  • mysql的分组group by
  • Swoole 介绍以及 编译安装
  • Ubuntu终端指令
  • python给json 转实体类加注释的代码实现
  • 绘制三角波与梯形波
  • 【Git】 git push 提示Not possible to fast-forward,无法提交也无法提交程序
  • 优思学院|为什么质量工程师在别人看是“救火“的呢?
  • VMware Explore | 联想与VMware扩大合作带来生成式AI和多云解决方案
  • 8月份徒弟企业面试后反馈的软件测试面试题(含金量高请收藏)
  • 私有云不是真正的云计算!
  • netperf 测试时延和吞吐
  • 安卓预制权限添加规则
  • D3JS简介
  • 系统架构设计师(第二版)学习笔记----系统工程
  • java spring cloud 企业工程管理系统源码+二次开发+定制化服务
  • IMX6ULL移植篇-boot 命令的学习
  • Python字典和集合操作指南:创建、获取值、修改和删除键值对,复制和遍历方法全解析
  • unity 接收拼接数据进行纹理替换且保存相机纹理到rtsp server(一)
  • 视频讲解|3014 含分布式电源的配电网优化重构
  • 分布式、锁、延时任务
  • Mojo 语言官网
  • JTS:02 使用WKB操作数据