<!-- -->
<template>
  <el-menu
    class="sidebar-el-menu"
    default-active=""
    @open="handleOpen"
    @close="handleClose"
    :default-openeds="[items[0].euId]"
  >
    <!-- 遍历菜单 -->
    <template v-for="(item) in items">
      <!-- 含有子菜单 -->
      <template v-if="item.children">
        <!-- 第一层 含有子菜单菜单 -->
        <el-submenu :index="item.euId" :key="item.title">
          <template slot="title">
            <div slot="title" @click="handleClick(item)">{{ item.title }}</div>
          </template>
          <menu-list :items="item.children" v-bind="$attrs" v-on="$listeners"></menu-list
          ><!--递归调用-->
        </el-submenu>
      </template>

      <!-- 第一层 不含子菜单  -->
      <template v-else>
        <el-menu-item :index="item.euId" :key="item.title">
          <div slot="title"  @click="handleClick(item)">{{ item.title }}</div>
        </el-menu-item>
      </template>
    </template>
  </el-menu>
</template>

<script>
export default {
  name: "MenuList",
  props: {
    items: Array,
    isCollapse: Boolean,
  },
  inheritAttrs:false,
  methods: {
    handleOpen(key, keyPath) {
      debugger
      
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
      
    },
    handleClick(item){
      // console.log(item.title);
      this.$emit('open',item)
    }
  },
};
</script>

<style lang="scss" scoped>
</style>
