<template>
<div>
<el-menu
ref="elMenuRef"
class="menu-type"
:unique-opened="true"
@close="menuClose"
>
<el-submenu :index="`${index}`" :key="item.id" v-for="(item ,index) in menuList" >
<template slot="title">
<div @click="subHandleClick(item)">
<span>{{ item.name}}</span>
</div>
</template>
<el-menu-item
:index="`${index}-${index2}`"
:key="item2.id"
v-for="(item2 , index2) in item.children"
style="color:#54667a"
@click="handleClick(item2)" >
<span class="icon" :style="{background: item2.color }"></span>
<span class="text">{{ item2.name }}</span></el-menu-item>
</el-submenu>
</el-menu>
</div>
</template>
methods: {
menuClose(index){
if(this.$refs.elMenuRef.openedMenus.length < 1){
this.$refs.elMenuRef.open(index)
}
},
handleClick(data){
this.$emit('menuHandleClick',data)
},
subHandleClick(data){
this.$emit('menuHandleClick',data)
this.$refs.elMenuRef.activeIndex = null
},
},