dragon_brg 2020-05-07 11:47 采纳率: 50%
浏览 403

elemelt 菜单的下拉一点就全部打开或关闭! 求大佬指教

父组件代码

 <el-menu :default-active='$route.path'
                        class="el-menu-vertical-demo"
                        background-color="#304156"
                        text-color="#fff"
                        collapse-transition=true
                        active-text-color="#409eff"
                        align = 'laft'
                        show-timeout = '0'
                        hide-timeout='0'
                        router="true"
                         @select="handleSelect"
                         :collapse="isCollapse"
                         unique-opened = true
                        >
                         <menutree :data="getpowertrees"></menutree>
                      </el-menu>

子组件代码

<template>
<div class="menutree">
    <label v-for="menu in data" :key="menu.id">
    <el-submenu :index="menu.powerPath" v-if="menu.childs">
        <template slot="title">
          <i class="el-icon-s-home"></i>
          <span>{{menu.powerName}}</span>
        </template>
        <label>
        <menutree :data="menu.childs"></menutree>
        </label>
    </el-submenu>
    <el-menu-item v-else :index="menu.powerPath">
      <i class="el-icon-s-home"></i>
        <span slot="title">{{menu.powerName}}</span>
    </el-menu-item>
    </label>
</div>
</template>
<script>
export default {
  name: 'menutree',
  data () {
    return {
      menu_data: {}
    }
  },
  props: ['data']
}
</script>

菜单格式

{
              id: 10,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '首页',
              powerPath: '/home',
              childs: null
            },
            {
              id: 20,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '计划管理',
              powerPath: 'null',
              childs: [
                {
                  id: 21,
                  parentId: 20,
                  icon: 'el-icon-s-home',
                  powerName: '实验计划',
                  powerPath: '/plan/test'
                },
                {
                  id: 22,
                  parentId: 20,
                  icon: 'el-icon-s-home',
                  powerName: '调度计划',
                  powerPath: '/plan/dispatch'
                },
                {
                  id: 30,
                  parentId: 0,
                  icon: 'el-icon-s-home',
                  powerName: '压气计划',
                  powerPath: '/plan/injection'
                }
              ]
            },
            {
              id: 40,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '变更审核',
              powerPath: 'alteration/audit',
              childs: null
            },
            {
              id: 50,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '作业管理',
              powerPath: 'null',
              childs: [
                {
                  id: 51,
                  parentId: 50,
                  icon: 'el-icon-s-home',
                  powerName: '实验作业',
                  powerPath: 'jobmana/sy-assignments'
                },
                {
                  id: 52,
                  parentId: 50,
                  icon: 'el-icon-s-home',
                  powerName: '压气作业',
                  powerPath: 'jobmana/yq-assignments'
                }
              ]
            }, {
              id: 60,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '数据采集',
              powerPath: 'null',
              childs: [
                {
                  id: 61,
                  parentId: 60,
                  icon: 'el-icon-s-home',
                  powerName: '动力数据',
                  powerPath: 'data/dl-data'
                },
                {
                  id: 62,
                  parentId: 60,
                  icon: 'el-icon-s-home',
                  powerName: '实验数据',
                  powerPath: 'data/sy-data'
                },
                {
                  id: 63,
                  parentId: 60,
                  icon: 'el-icon-s-home',
                  powerName: '压气数据',
                  powerPath: 'data/yq-data'
                }
              ]
            }, {
              id: 70,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '设备管理',
              powerPath: 'device/device-manager',
              childs: null
            },
            {
              id: 80,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '数据中心',
              powerPath: 'null',
              childs: [
                {
                  id: 81,
                  parentId: 80,
                  icon: 'el-icon-s-home',
                  powerName: '实验数据',
                  powerPath: 'null'
                },
                {
                  id: 82,
                  parentId: 80,
                  icon: 'el-icon-s-home',
                  powerName: '动力数据',
                  powerPath: 'null'
                },
                {
                  id: 83,
                  parentId: 80,
                  icon: 'el-icon-s-home',
                  powerName: '压气数据',
                  powerPath: 'null'
                }
              ]
            },
            {
              id: 90,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '账管理号',
              powerPath: 'null',
              childs: [
                {
                  id: 91,
                  parentId: 90,
                  icon: 'el-icon-s-home',
                  powerName: '账号权限',
                  powerPath: 'account/authority'
                },
                {
                  id: 92,
                  parentId: 90,
                  icon: 'el-icon-s-home',
                  powerName: '组织架构',
                  powerPath: 'account/organization'
                }
              ]
            },
            {
              id: 100,
              parentId: 0,
              icon: 'el-icon-s-home',
              powerName: '系统管理',
              powerPath: 'null',
              childs: [
                {
                  id: 101,
                  parentId: 100,
                  icon: 'el-icon-s-home',
                  powerName: '系统设置',
                  powerPath: 'system/set'
                },
                {
                  id: 101,
                  parentId: 100,
                  icon: 'el-icon-s-home',
                  powerName: '系统日志',
                  powerPath: 'system/log'
                }
              ]
            }
          ]

点一个就全部展开了
图片说明

  • 写回答

1条回答 默认 最新

  • 禅思院 前端领域优质创作者 2024-02-22 09:54
    关注

    img


    看这个

    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境