dragon_brg 2020-05-07 11:47 采纳率: 0%
浏览 397

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


    看这个

    评论

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示