Bez popisu

SidebarItem.vue 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div>
  3. <template v-for="item in routes">
  4. <router-link v-if="!item.hidden&&item.noDropdown&&item.children.length>0" :to="item.path+'/'+item.children[0].path">
  5. <el-menu-item :index="item.path+'/'+item.children[0].path">
  6. <icon-svg v-if='item.icon' :icon-class="item.icon" /> {{item.children[0].name}}
  7. </el-menu-item>
  8. </router-link>
  9. <el-submenu :index="item.name" v-if="!item.noDropdown&&!item.hidden">
  10. <template slot="title">
  11. <icon-svg v-if='item.icon' :icon-class="item.icon" /> {{item.name}}
  12. </template>
  13. <template v-for="child in item.children" v-if='!child.hidden'>
  14. <sidebar-item class='menu-indent' v-if='child.children&&child.children.length>0' :routes='[child]'> </sidebar-item>
  15. <router-link v-else class="menu-indent" :to="item.path+'/'+child.path">
  16. <el-menu-item :index="item.path+'/'+child.path">
  17. {{child.name}}
  18. </el-menu-item>
  19. </router-link>
  20. </template>
  21. </el-submenu>
  22. </template>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: 'SidebarItem',
  28. props: {
  29. routes: {
  30. type: Array
  31. }
  32. }
  33. }
  34. </script>
  35. <style rel="stylesheet/scss" lang="scss" scoped>
  36. .svg-icon {
  37. margin-right: 10px;
  38. }
  39. .hideSidebar .menu-indent{
  40. display: block;
  41. text-indent: 10px;
  42. }
  43. </style>