<template>
  <div>
    <template v-if="!item.children">
      <app-link :to="item.path">
        <el-menu-item :index="item.path">
          <item
            :icon="item.meta.icon"
            :title="item.meta.title"
          />
        </el-menu-item>
      </app-link>
    </template>
    <el-submenu
      v-else
      ref="subMenu"
      :index="item.path"
    >
      <template #title>
        <item
          :icon="item.meta.icon"
          :title="item.meta.title"
        />
      </template>
      <sidebar-item
        v-for="child in item.children"
        :key="child.path"
        class="nest-menu"
        :item="child"
      />
    </el-submenu>
  </div>
</template>

<script>
import Item from './Item'
import AppLink from './Link'
import FixiOSBug from './FixiOSBug'

export default {
  name: 'SidebarItem',
  components: {
    Item,
    AppLink
  },
  mixins: [FixiOSBug],
  props: {
    item: {
      type: Object,
      required: true
    }
  }
}
</script>
