Vue3 项目实战 —— 后台管理系统( pc端 ) —— 动态多级导航菜单顶部侧边联动

news2024/11/17 13:51:09

前期回顾     

0.活在风浪里的博客_CSDN博客-vue2,开源项目,Js领域博主0.活在风浪里擅长vue2,开源项目,Js,等方面的知识,0.活在风浪里关注css,safari,html5,scss,elementui,前端,es6,正则表达式,vue.js,express,ajax,webpack,echarts,json,html,typescript,sass,https,面试,chrome,npm,javascript,xhtml,前端框架,node.js,yarn,css3领域.https://blog.csdn.net/m0_57904695?spm=1001.2101.3001.5343

目录

 home.vue

 结语:


 

 

面试官:如果有多层菜单结构,你怎么把它渲染上去?

第一种使用for循环,是不行的,因为你不确定他有多少层级而且for循环嵌套过多,不易维护,结构不明

 第二种: 拿到菜单数据,使用计算属性将由children的有层级的结构出来,将没有层级的也同样给结构出来,这样只是将有子级的和没有子级的菜单给分开了,同样有子级的还是要写多重数循环去循环它,显然又变成了第一种的问题,也不合适

 第三种: 使用递归组件,什么是递归组件?就是子组件在运行过程中调用自己,

 


需求: 顶部展示一级二级菜单,点击顶部二级菜单,如果有三级就在左侧展示二级剩余菜单,使用element-plus

 home.vue

<template>
  <div>
    <!-- 需求: 顶部展示一级二级菜单,点击顶部二级菜单,如果有三级就在左侧展示二级剩余菜单,使用element-plus -->
    <!-- 顶部菜单 -->
    <el-menu
      default-active="1"
      class="el-menu-vertical-demo"
      mode="horizontal"
      background-color="#eee"
    >
      <template v-for="item in menuObj">
        <!-- 如果有二级菜单使用 el-sub-menu,如果没有使用  el-menu-item-->
        <el-sub-menu
          :key="item.path"
          :index="item.path"
          :disabled="item.disabled"
          v-if="item.children && item.children.length > 0"
        >
          <template #title>
            <i :class="item.meta.icon"></i>
            <span>{{ item.meta.title }}</span>
          </template>

          <el-menu-item
            v-for="item2 in item.children"
            :key="item2.path"
            :index="item2.path"
            :disabled="item2.disabled"
            @click="handleClick2(item2)"
          >
            <i :class="item2.meta.icon"></i>
            <div class="text2-icon">
              <span>
                {{ item2.meta.title }}
              </span>
              <el-icon v-if="item2.children" :size="15" class="icon">
                <ArrowRight />
              </el-icon>
            </div>
          </el-menu-item>
        </el-sub-menu>

        <!--不使用 el-sbu-menu 独立一级-->
        <el-menu-item :index="item.path" v-else>
          <i :class="item.meta.icon"></i>
          <span>{{ item.meta.title }}</span></el-menu-item
        >
      </template>
    </el-menu>

    <!-- 左侧二级剩余所有菜单 leftMenu-->
    <!-- 递归组件 -->
    <div class="left-box" v-if="flag">
      <menu-tree :menuList="leftMenu"></menu-tree>
    </div>
  </div>
</template>
<script setup>
// 引入递归组件
import MenuTree from "./MenuTree.vue";

//所有菜单数据
let menuObj = [
  {
    path: "/home",
    name: "首页",
    children: null,
    meta: {
      title: "首页",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-home",
    },
  },
  {
    path: "#",
    name: "系统管理",
    children: [
      {
        path: "/system/department",
        name: "部门管理",
        children: null,
        meta: {
          title: "部门管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-office-building",
        },
      },
      {
        path: "/system/role",
        name: "角色管理",
        children: null,
        meta: {
          title: "角色管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-cold-drink",
        },
      },
      {
        path: "/system/user",
        name: "用户管理",
        children: null,
        meta: {
          title: "用户管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-user",
        },
      },
      {
        path: "/system/dictionaries",
        name: "字典管理",
        children: null,
        meta: {
          title: "字典管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-notebook-2",
        },
      },
      {
        path: "/system/logonLog",
        name: "操作日志",
        children: null,
        meta: {
          title: "操作日志",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-document",
        },
      },
      {
        path: "/system/maintain",
        name: "企业信息维护",
        children: null,
        meta: {
          title: "企业信息维护",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-school",
        },
      },
    ],
    meta: {
      title: "系统管理",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-setting",
    },
  },
  {
    path: "/IntelligentAuthorizationManagement",
    name: "智能授权管理",
    children: [
      {
        path: "/dataAnalysisAll/Authorize",
        name: "隐私授权维护",
        children: [
          {
            path: "/dataAnalysisAll/Authorize/Purpose",
            name: "使用目的管理",
            children:
              // 11111
              [
                {
                  path: "/IntelligentAtionManagement",
                  name: "1",
                  children: [
                    {
                      path: "/dataAnalysisAll/Authorize",
                      name: "1-1",
                      children: [
                        {
                          path: "/dataAll/Authorize/Purpose",
                          name: "1-1-2",
                          children: null,
                          meta: {
                            title: "2",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-more-outline",
                          },
                        },
                        {
                          path: "/dataAna/Authorize/privacy",
                          name: "1-1-3",
                          children: null,
                          meta: {
                            title: "3",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-view",
                          },
                        },
                        {
                          path: "/dataAnalyAuthorize/scene",
                          name: "1-1-4",
                          children: null,
                          meta: {
                            title: "4",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-film",
                          },
                        },
                        {
                          path: "/dataAnalysthorize/applica",
                          name: "1-1-5",
                          children: null,
                          meta: {
                            title: "5",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-s-platform",
                          },
                        },
                      ],
                      meta: {
                        title: "隐私授权维护666",
                        isLink: false,
                        isHide: false,
                        isKeepAlive: false,
                        isAffix: false,
                        isIframe: false,
                        icon: "el-icon-s-check",
                      },
                    },
                  ],
                  meta: {
                    title: "智能授权管理222",
                    isLink: false,
                    isHide: false,
                    isKeepAlive: false,
                    isAffix: false,
                    isIframe: false,
                    icon: "el-icon-circle-check",
                  },
                },
              ],
            // 22222
            meta: {
              title: "使用目的管理",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-more-outline",
            },
          },
          {
            path: "/dataAnalysisAll/Authorize/privacy",
            name: "隐私项管理",
            children: null,
            meta: {
              title: "隐私项管理",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-view",
            },
          },
          {
            path: "/dataAnalysisAll/Authorize/scene",
            name: "业务场景管理",
            children: null,
            meta: {
              title: "业务场景管理",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-film",
            },
          },
          {
            path: "/dataAnalysisAll/Authorize/applica",
            name: "客户应用管理",
            children: null,
            meta: {
              title: "客户应用管理",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-s-platform",
            },
          },
        ],
        meta: {
          title: "隐私授权维护",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-check",
        },
      },
      {
        path: "/dataAnalysisAll/modelAgreement",
        name: "协议管理",
        children: [
          {
            path: "/dataAnalysisAll/modelAgreement/makeTemplate",
            name: "系统模板",
            children: null,
            meta: {
              title: "系统模板",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-c-scale-to-original",
            },
          },
          {
            path: "/dataAnalysisAll/modelAgreement/templateQueries",
            name: "自定义模板",
            children: null,
            meta: {
              title: "自定义模板",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-edit-outline",
            },
          },
          {
            path: "/dataAnalysisAll/modelAgreement/customTemplate",
            name: "协议正文",
            children: null,
            meta: {
              title: "协议正文",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-document",
            },
          },
        ],
        meta: {
          title: "协议管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-tickets",
        },
      },
      {
        path: "/dataAnalysisAll/ultraviresdetection",
        name: "越权检测",
        children: [
          {
            path: "/dataAnalysisAll/ultraviresdetection/authorizeupload",
            name: "用户授权数据上传",
            children: null,
            meta: {
              title: "用户授权数据上传",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-upload2",
            },
          },
          {
            path: "/dataAnalysisAll/ultraviresdetection/userauthorization",
            name: "用户授权数据",
            children: null,
            meta: {
              title: "用户授权数据",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-collection-tag",
            },
          },
          {
            path: "/dataAnalysisAll/ultraviresdetection/authorizationtestresults",
            name: "越权检测结果",
            children: null,
            meta: {
              title: "越权检测结果",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-warning-outline",
            },
          },
        ],
        meta: {
          title: "越权检测",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-help",
        },
      },
    ],
    meta: {
      title: "智能授权管理",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-circle-check",
    },
  },
  {
    path: "/compliance",
    name: "合规监控中心",
    children: [
      {
        path: "/compliance/detail",
        name: "监控视图",
        children: null,
        meta: {
          title: "监控视图",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-grid",
        },
      },
      {
        path: "/compliance/apiReport",
        name: "API日志",
        children: null,
        meta: {
          title: "API日志",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-top-right",
        },
      },
      {
        path: "/compliance/riskReporting",
        name: "风险报告",
        children: [
          {
            path: "/compliance/riskReporting/dereport",
            name: "a",
            children:   [
                {
                  path: "/IntelligentAtionManagement",
                  name: "a-1",
                  children: [
                    {
                      path: "/dataAnalysisAll/Authorize",
                      name: "a-1-1",
                      children: [
                        {
                          path: "/dataAll/Authorize/Purpose",
                          name: "a-1-2",
                          children: null,
                          meta: {
                            title: "2",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-more-outline",
                          },
                        },
                        {
                          path: "/dataAna/Authorize/privacy",
                          name: "a-1-3",
                          children: null,
                          meta: {
                            title: "3",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-view",
                          },
                        },
                        {
                          path: "/dataAnalyAuthorize/scene",
                          name: "a-1-4",
                          children: null,
                          meta: {
                            title: "4",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-film",
                          },
                        },
                        {
                          path: "/dataAnalysthorize/applica",
                          name: "a-1-5",
                          children: null,
                          meta: {
                            title: "5",
                            isLink: false,
                            isHide: false,
                            isKeepAlive: false,
                            isAffix: false,
                            isIframe: false,
                            icon: "el-icon-s-platform",
                          },
                        },
                      ],
                      meta: {
                        title: "5222",
                        isLink: false,
                        isHide: false,
                        isKeepAlive: false,
                        isAffix: false,
                        isIframe: false,
                        icon: "el-icon-s-check",
                      },
                    },
                  ],
                  meta: {
                    title: "4222",
                    isLink: false,
                    isHide: false,
                    isKeepAlive: false,
                    isAffix: false,
                    isIframe: false,
                    icon: "el-icon-circle-check",
                  },
                },
              ],
            meta: {
              title: "问卷评估报告",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-tickets",
            },
          },
          {
            path: "/compliance/riskReporting/globalReporting",
            name: "全局风险报告",
            children: null,
            meta: {
              title: "全局风险报告",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-film",
            },
          },
        ],
        meta: {
          title: "风险报告",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-opportunity",
        },
      },
      {
        path: "/compliance/riskdisposal",
        name: "风险处置工作台",
        children: [
          {
            path: "/compliance/riskdisposal/riskTobeAllocated",
            name: "待分配风险",
            children: null,
            meta: {
              title: "待分配风险",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-sold-out",
            },
          },
          {
            path: "/compliance/riskdisposal/riskToeDisposed",
            name: "待处置风险",
            children: null,
            meta: {
              title: "待处置风险",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-sell",
            },
          },
          {
            path: "/compliance/riskdisposal/allRisksQuery",
            name: "全部风险查询",
            children: null,
            meta: {
              title: "全部风险查询",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-search",
            },
          },
          {
            path: "/compliance/riskdisposal/myRiskQuery",
            name: "我的风险查询",
            children: null,
            meta: {
              title: "我的风险查询",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-magic-stick",
            },
          },
        ],
        meta: {
          title: "风险处置工作台",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-box",
        },
      },
    ],
    meta: {
      title: "合规监控中心",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-goods",
    },
  },
  {
    path: "/dataAnalysis",
    name: "数据分析处理",
    children: [
      {
        path: "/dataAnalysis/system",
        name: "数据分析",
        children: [
          {
            path: "/dataAnalysis/system/sourceData",
            name: "源数据分析",
            children: null,
            meta: {
              title: "源数据分析",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-data-analysis",
            },
          },
          {
            path: "/dataAnalysis/system/catalogueData",
            name: "目录数据分析",
            children: null,
            meta: {
              title: "目录数据分析",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-notebook-1",
            },
          },
        ],
        meta: {
          title: "数据分析",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-management",
        },
      },
      {
        path: "/dataAnalysis/fileDetection",
        name: "文件检测",
        children: [
          {
            path: "/dataAnalysis/fileDetection/uploadfile",
            name: "知情授权书文件检测",
            children: null,
            meta: {
              title: "知情授权书文件检测",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-tickets",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/informedConsent",
            name: "知情授权书检测查询",
            children: null,
            meta: {
              title: "知情授权书检测查询",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-document-checked",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/privacydetection",
            name: "隐私协议文件检测",
            children: null,
            meta: {
              title: "隐私协议文件检测",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-collection-tag",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/privacyquery",
            name: "隐私协议检测查询",
            children: null,
            meta: {
              title: "隐私协议检测查询",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-collection",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/entrustAgreement",
            name: "委托处理协议",
            children: null,
            meta: {
              title: "委托处理协议",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-top-right",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/serveAgreement",
            name: "服务协议",
            children: null,
            meta: {
              title: "服务协议",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-discount",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/useAgreement",
            name: "使用协议",
            children: null,
            meta: {
              title: "使用协议",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-tickets",
            },
          },
          {
            path: "/dataAnalysis/fileDetection/fileScan",
            name: "文件扫描",
            children: null,
            meta: {
              title: "文件扫描",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-wallet",
            },
          },
        ],
        meta: {
          title: "文件检测",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-claim",
        },
      },
    ],
    meta: {
      title: "数据分析处理",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-ticket",
    },
  },
  {
    path: "/pia",
    name: "PIA评估",
    children: [
      {
        path: "/pia/templates",
        name: "评估模板",
        children: null,
        meta: {
          title: "评估模板",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-order",
        },
      },
      {
        path: "/pia/evaluate",
        name: "PIA评估处理",
        children: null,
        meta: {
          title: "PIA评估处理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-help",
        },
      },
      {
        path: "/pia/riskScore",
        name: "风险评分配置",
        children: null,
        meta: {
          title: "风险评分配置",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-collection",
        },
      },
      {
        path: "/pia/riskClassify",
        name: "风险分类查询",
        children: null,
        meta: {
          title: "风险分类查询",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-shop",
        },
      },
      {
        path: "/pia/threat",
        name: "威胁库查询",
        children: null,
        meta: {
          title: "威胁库查询",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-opportunity",
        },
      },
      {
        path: "/pia/vulnerability",
        name: "漏洞库查询",
        children: null,
        meta: {
          title: "漏洞库查询",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-goblet-square-full",
        },
      },
    ],
    meta: {
      title: "PIA评估",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-promotion",
    },
  },
  {
    path: "/daily",
    name: "日常管理",
    children: [
      {
        path: "/daily/architecturemaintenance",
        name: "合规组织架构维护",
        children: null,
        meta: {
          title: "合规组织架构维护",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-school",
        },
      },
      {
        path: "/daily/organization",
        name: "合规人员管理",
        children: null,
        meta: {
          title: "合规人员管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-coordinate",
        },
      },
      {
        path: "/daily/rules",
        name: "规章制度",
        children: null,
        meta: {
          title: "规章制度",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-document-copy",
        },
      },
      {
        path: "/daily/compliance",
        name: "规章制度模板",
        children: null,
        meta: {
          title: "规章制度模板",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-tickets",
        },
      },
      {
        path: "/daily/contract",
        name: "合同协议",
        children: null,
        meta: {
          title: "合同协议",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-folder-opened",
        },
      },
      {
        path: "/daily/contractcompliance",
        name: "合同协议模板",
        children: null,
        meta: {
          title: "合同协议模板",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-folder",
        },
      },
      {
        path: "/daily/training",
        name: "培训",
        children: null,
        meta: {
          title: "培训",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-data-line",
        },
      },
    ],
    meta: {
      title: "日常管理",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-cpu",
    },
  },
  {
    path: "/repository",
    name: "知识库",
    children: [
      {
        path: "/repository/systemKnow",
        name: "系统问卷",
        children: null,
        meta: {
          title: "系统问卷",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-document",
        },
      },
      {
        path: "/repository/systemLaw",
        name: "法律法规",
        children: null,
        meta: {
          title: "法律法规",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-view",
        },
      },
      {
        path: "/repository/risk",
        name: "风险点大全",
        children: null,
        meta: {
          title: "风险点大全",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-wind-power",
        },
      },
      {
        path: "/repository/ques",
        name: "问卷记录",
        children: null,
        meta: {
          title: "问卷记录",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-money",
        },
      },
    ],
    meta: {
      title: "知识库",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-coin",
    },
  },
  {
    path: "/assetcenter",
    name: "资产中心",
    children: [
      {
        path: "/assetcenter/serviceassetdiscovery",
        name: "服务资产发现",
        children: null,
        meta: {
          title: "服务资产发现",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-set-up",
        },
      },
      {
        path: "/assetcenter/logassetdiscovery",
        name: "日志发现",
        children: [
          {
            path: "/assetcenter/logassetdiscovery/obviousfindings",
            name: "日志发现明细",
            children: null,
            meta: {
              title: "日志发现明细",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-tickets",
            },
          },
          {
            path: "/assetcenter/logassetdiscovery/logalarm",
            name: "日志告警",
            children: null,
            meta: {
              title: "日志告警",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-warning-outline",
            },
          },
        ],
        meta: {
          title: "日志发现",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-notebook-1",
        },
      },
      {
        path: "/assetcenter/dataassetdiscovery",
        name: "数据库资产发现",
        children: [
          {
            path: "/assetcenter/dataassetdiscovery/assettaskconfiguration",
            name: "资产任务配置",
            children: null,
            meta: {
              title: "资产任务配置",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-s-tools",
            },
          },
          {
            path: "/assetcenter/dataassetdiscovery/rulemanagement",
            name: "规则管理",
            children: null,
            meta: {
              title: "规则管理",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-setting",
            },
          },
          {
            path: "/assetcenter/dataassetdiscovery/resultexample",
            name: "DB结果实例",
            children: null,
            meta: {
              title: "DB结果实例",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-s-operation",
            },
          },
          {
            path: "/assetcenter/dataassetdiscovery/resultdatasheet",
            name: "结果数据表",
            children: null,
            meta: {
              title: "结果数据表",
              isLink: false,
              isHide: false,
              isKeepAlive: false,
              isAffix: false,
              isIframe: false,
              icon: "el-icon-files",
            },
          },
        ],
        meta: {
          title: "数据库资产发现",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-shop",
        },
      },
    ],
    meta: {
      title: "资产中心",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-finance",
    },
  },
  {
    path: "/multitaskmanagement",
    name: "多任务管理",
    children: [
      {
        path: "/multitaskmanagement/taskCollection",
        name: "任务集合管理",
        children: null,
        meta: {
          title: "任务集合管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-grid",
        },
      },
      {
        path: "/multitaskmanagement/taskmanagement",
        name: "任务管理",
        children: null,
        meta: {
          title: "任务管理",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-shopping-bag-2",
        },
      },
      {
        path: "/multitaskmanagement/dispatchlog",
        name: "调度日志",
        children: null,
        meta: {
          title: "调度日志",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-chat-line-square",
        },
      },
    ],
    meta: {
      title: "多任务管理",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-s-order",
    },
  },
  {
    path: "/Policymanagement",
    name: "策略管理中心",
    children: [
      {
        path: "/Policymanagement/hierarchicalstrategy",
        name: "分级策略",
        children: null,
        meta: {
          title: "分级策略",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-unfold",
        },
      },
      {
        path: "/Policymanagement/classificationpolicy",
        name: "分类策略",
        children: null,
        meta: {
          title: "分类策略",
          isLink: false,
          isHide: false,
          isKeepAlive: false,
          isAffix: false,
          isIframe: false,
          icon: "el-icon-s-grid",
        },
      },
    ],
    meta: {
      title: "策略管理中心",
      isLink: false,
      isHide: false,
      isKeepAlive: false,
      isAffix: false,
      isIframe: false,
      icon: "el-icon-help",
    },
  },
];

// 三级菜单数据
let leftMenu = ref([]);
// 是否显示三级菜单(左侧的显示时机)
let flag = ref(false);
// 点击二级菜单展示左侧菜单
const handleClick2 = (item) => {
  if (item.children) {
    leftMenu.value = item.children;
    flag.value = true;
  } else {
    leftMenu.value = [];
    flag.value = false;
  }
  console.log("😂👨🏾‍❤️‍👨🏼==>:", item);
};
</script>

<style lang="scss" scoped>
.left-box {
  width: 200px;
  height: calc(100vh - 58.4px);
  background-color: #545c64;
  color: #fff;
  animation: fold linear 0.1s;
}

@keyframes fold {
  0% {
    width: 0;
  }

  50% {
    width: 100px;
  }

  100% {
    width: 200px;
  }
}

.text2-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #929396;

  .icon {
    position: absolute;
    right: 10px;
  }
}
</style>

MenuTree.vue (子组件)

<template>
  <el-menu
    v-for="menu in menuList"
    :key="menu.name"
    class="el-menu-demo"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    @select="handleSelect"
    :default-active="activeIndex"
    :default-openeds="openeds"
    :unique-opened="true"
  >
    <!-- 如果当前有子菜单,则显示 el-sub-menu ,在el-sub-menu 里调用 递归组件 -->
    <el-sub-menu
      v-if="menu.children && menu.children.length > 0"
      :index="menu.name"
      ><template #title><i :class="menu.icon"></i>{{ menu.name }}</template
      ><!-- 调用自身  此处是[重点] !!! -->
      <MenuTree :menuList="menu.children"></MenuTree>
    </el-sub-menu>
    <!-- 如果没有子菜单,则显示el-menu-item --><el-menu-item
      v-else
      :index="menu.name"
      ><i :class="menu.icon"></i>{{ menu.name }}</el-menu-item
    ></el-menu
  ><!--注意项
1.这里的MenuTree 是vue的递归组件,实际上就是组件自己调用自己,这里组件中调用自己的组件名字是name属性。
2.一点要在递归组件中加上判断条件,否则可能会造成爆栈。
3.这里的属性名字请根据自己后端传递的数据字段名字改变。 -->
</template>

<!-- 1:非语法糖定义name属性 -->
<!-- <script lang="ts">
export default defineComponent({
  name: "MenuTree",
  props: {
    menuList: {
      type: Array,
      default: () => [],
    },
  },
  setup() {
    return {};
  },
});
</script> -->

<!-- 2:语法糖定义name属性
    详细看 https://blog.csdn.net/m0_57904695/article/details/128318224?spm=1001.2014.3001.5502
-->
<script>
export default {
  name: "MenuTree",
};
</script>

<script setup>
defineProps({
  menuList: {
    type: Array,
    default: () => [],
  },
});
//默认激活的菜单,展开的菜单第一项
const activeIndex = ref("a-1-2");

// 默认展开的菜单父级
const openeds = ref(["使用目的管理", "1", "1-1", "a", "a-1", "a-1-1"]);
// 菜单点击事件
const handleSelect = (key, keyPath) => {
  console.log(key, keyPath);
};
</script>

直接拷贝就能使用,参考,其实没什么难度,比较简单!

如图有真相

 


结语:

新年快乐 kk

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/173227.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

离散数学-图论-图的矩阵表示(12.1)

图的矩阵表示 1 关联矩阵 定义&#xff1a;设无向图G<V,E>,V{v1,v2,⋅⋅⋅,vnv_1,v_2,,v_nv1​,v2​,⋅⋅⋅,vn​},E{e1,e2,⋅⋅⋅,eme_1,e_2,,e_me1​,e2​,⋅⋅⋅,em​},令mijm_{ij}mij​为顶点viv_ivi​与边eje_jej​的关联次数&#xff0c;则称(mij)nm(m_{ij})_{nm}…

九龙证券|景气度复苏与库存拐点双击,这个行业获主力看好!

今天计算机职业、电子、非银金融职业净流入规划居前&#xff0c;9股主力资金净流入超2亿元。 证券时报数据宝统计&#xff0c;今天沪深两市主力资金净流出46.1亿元&#xff0c;其间创业板净流出3.57亿元&#xff0c;沪深300成份股净流入28.21亿元。 申万一级职业中&#xff0c…

SpringAMQP - Work Queue 工作消息队列

目录 介绍 案例 测试 改进&#xff1a; 介绍 Work queues也被称为&#xff08;Task queues&#xff09;&#xff0c;任务模型简单来说就是让多个消费者绑定到一个队列&#xff0c;共同消费队列中的消息当消息处理比较耗时的时候&#xff0c;可能生产消息的速度会远远大于消…

机器人与未来

我们生活在“普适机器人”时代&#xff0c;机器人将像今天的智能手机一样融入日常生活&#xff0c;完成许多专门任务&#xff0c;并经常与人类并肩工作。 机器人革命将创造一个比现在更加生动和充满活力的未来。 到 2022 年&#xff0c;机器人将获得如此大的吸引力&#xff0…

全国地名点地统计模式分析

前言用不同的空间点模式分析方法&#xff0c;综合得出全国地名数据点的空间分布模式属于随机分布、均匀分布、聚集分布中的哪一种。一、点模式分析空间点模式分析是一种根据地理实体或事件的空间位置研究其分布模式的空间分析方法 。 空间点分布模式通常分为三种&#xff1a;随…

从汇编的角度去审视函数的调用【函数栈帧】

文章目录函数栈帧栈寄存器相关汇编指令函数栈帧的创建函数栈帧的销毁函数栈帧 我们在写C语言代码的时候&#xff0c;经常会把一个独立的功能抽象为函数&#xff0c;所以C程序是以函数为基本单位的。 那函数是如何调用的&#xff1f;函数的返回值又是如何待会的&#xff1f;函数…

17种编程语言实现排序算法-冒泡排序

开源地址 https://gitee.com/lblbc/simple-works/tree/master/sort 覆盖语言&#xff1a;C、C、C#、Java、Kotlin、Dart、Go、JavaScript(JS)、TypeScript(TS)、ArkTS、swift、PHP。 覆盖平台&#xff1a;安卓(Java、Kotlin)、iOS(SwiftUI)、Flutter(Dart)、Window桌面(C#)、前…

离散数学-集合论-函数(10)

函数 1 函数的概念 1.1 函数的定义 设&#x1d453;是非空集A到B的关系, 如果对每个&#x1d465;∈A, 都存在唯一的&#x1d466;∈B, 使得<&#x1d465;, &#x1d466;>∈&#x1d453;, 则称关系&#x1d453;为A到B的函数(Function), 也可称为映射(Mapping)或变…

PID优化系列之给定值斜坡函数(PLC代码+Simulink仿真测试)

很多变频器里的工艺PID,都有"PID给定值变化时间"这个参数,这里的给定值变化时间我们可以利用斜坡函数实现,当然也可以利用PT1 低通滤波器对给定值进行平滑。给定值缓慢变化在很多闭环控制系统里很重要,比如收放卷在初始建张阶段目标值不建议突变容易将卷材拉断(…

聊聊外包团队的高效管理机制

这是鼎叔的第四十七篇原创文章。行业大牛和刚毕业的小白&#xff0c;都可以进来聊聊。欢迎关注本人专栏和微信公众号《敏捷测试转型》&#xff0c;大量原创思考文章陆续推出。对于大规模的外包团队&#xff0c;需要一个易用的外包管理OA系统&#xff0c;才能提高日常交付效率。…

LINUX学习之时间日期类命令(五)

date命令 命令描述 date命令用于在Linux系统中显示或设置当前系统时间。它可以显示当前日期和时间&#xff0c;并允许用户格式化输出。它还可以用于将系统时间设置为指定的日期和时间。使用格式化字符串&#xff0c;可以自定义输出格式 以下是data命令的常用参数&#xff1a…

【Simulink】使用Model Explorer设置模块变量初值

问题背景 最近在学习滑模控制&#xff0c;看到b站上的视频和文章&#xff0c;打算自己照着做一遍&#xff1a; 1、滑模控制的基本原理实际仿真中却遇到了一个小问题&#xff0c;不知道怎么设置变量x1的初值&#xff08;不能用pulse generator给初始脉冲&#xff09; 这里的x1是…

【JavaEE】单例模式(饿汉懒汉)

目录 前言&#xff1a; 单线程下的单例模式 饿汉模式 懒汉模式 多线程下的单例模式 懒汉模式的修改 1.加锁 2.有条件的加锁 3.解决内存可见性和指令重排序 前言&#xff1a; 本片文章介绍设计模式中的一个模式——单例模式。 单例模式就是只允许创建出一个实例的类。…

离散数学-图论-树(13)

树 1 无向树及其性质 定义1&#xff1a;连通无回路的无向图称为无向树,简称树.每个连通分支都是树的无向图称为森林.平凡图称为平凡树.在无向树中,悬挂顶点称为树叶,度数大于或等于2的顶点称为分支点. 定义2 设G<V,E>是n阶m条边的无向图&#xff0c;则下面各命题是等价…

c语言attribute关键字参数(详细)总结附示例快速掌握

目录一、简介二、参数详解2.1 section&#xff1a;自定义段2.2 aligned&#xff1a;对齐2.3 packed&#xff1a;对齐2.4 format&#xff1a;检查函数变参格式2.5 used2.6 unused2.7 at 绝对定位2.8 constructor2.9 destructor2.10 weak&#xff1a;弱声明2.11 alias&#xff1a…

macOS spotlight 聚焦 搜索范围自定义

文章目录Intro禁用不需要的查找范围&#xff0c;减少 spotlight 工作量/资源损耗搜索结果中的每个分类各自代表什么&#xff1f;Intro MBA升级系统之后&#xff0c;第一次充满电用了12h&#xff0c;之后的使用过程中掉电也很快。 新版本信息&#xff1a;macOS Ventura 13.1 (2…

I.MX6ULL裸机开发笔记1:启动方式

目录 启动模式设置步骤 1、三大模式 2.选择内部介质 3.选择接口编号 4.介质属性 原理图 芯片手册截图 开机相关全部引脚 启动设置表 启动模式设置步骤 1、三大模式 熔丝模式&#xff1a;烧录一次&#xff0c;发布产品外部模式&#xff1a;USB、串口等内部&#xff1a…

Windows系统下利用Anaconda搭建MXNet框架

1、mxnet MXNet 是一个深度学习库&#xff0c;类似于Theano 和 TensorFlow。最近想搞下深度学习&#xff0c;于是便安装mxnet。之前安装过TensorFlow&#xff0c;也踩了很多坑&#xff0c;可谓是历经波折。有的时候&#xff0c;配置环境真的是一门玄学。 2、关于网上的一些教…

手把手教你学习单片机-硬件基础知识

去耦电容的应用 C16 和 C19 起到的作 用是一样的,C10 的作用和他们两个不一样。 容值比较大的电容,理论上可以理解成水缸或者水池子,同时,大家可以直接把电流理 解成水流。 作用一,缓冲作用。当上电的瞬间,电流从电源处流下来的时候,不稳定,容易冲击电 子器件,加个…

基于云的文档管理系统——随时随地办公

如果您正在建立现代数字业务&#xff0c;您需要灵活地移动和分配您的劳动力。 DocuWare 移动劳动力解决方案可帮助您构建新的生产力模式&#xff1a;随时随地、任何设备。 毫不费力地捕捉、即时访问、始终安全 DocuWare 文档管理和工作流程自动化意味着当前流程的业务信息。 访…