<!-- -->
<template>
  <el-menu
    class="sidebar-el-menu"
    default-active=""
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
  >
    <!-- 遍历菜单 -->
    <template v-for="item in items">
      <!-- 含有子菜单 -->
      <template v-if="item.children">
        <!-- 第一层 含有子菜单菜单 -->
        <el-submenu :index="item.title" :key="item.title">
          <template slot="title">
            <span slot="title">{{ item.title }}</span>
          </template>
          <menu-list :items="item.children"></menu-list
          ><!--递归调用-->
        </el-submenu>
      </template>

      <!-- 第一层 不含子菜单  -->
      <template v-else>
        <el-menu-item :index="item.title" :key="item.title">
          <!-- <i :class="item.meta.icon"></i> -->
          <span slot="title">{{ item.title }}</span>
        </el-menu-item>
      </template>
    </template>
  </el-menu>
</template>

<script>
export default {
  name: "MenuList",
  props: {
    items: Array,
    isCollapse: Boolean,
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

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