Sidebar.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="sidebar">
  3. <el-menu :default-active="onRoutes" class="el-menu-vertical-demo" theme="dark" unique-opened router>
  4. <template v-for="item in items">
  5. <template v-if="item.subs">
  6. <el-submenu :index="item.index">
  7. <template slot="title"><i class="el-icon-menu"></i>{{ item.title }}</template>
  8. <el-menu-item v-for="subItem in item.subs" :index="subItem.index">{{ subItem.title }}
  9. </el-menu-item>
  10. </el-submenu>
  11. </template>
  12. <template v-else>
  13. <el-menu-item :index="item.index">
  14. <i class="el-icon-setting"></i>{{ item.title }}
  15. </el-menu-item>
  16. </template>
  17. </template>
  18. </el-menu>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. items: [
  26. {
  27. index: 'readme',
  28. title: '自述'
  29. },
  30. {
  31. index: '2',
  32. title: '表格',
  33. subs: [
  34. {
  35. index: 'basetable',
  36. title: '基础表格'
  37. },
  38. {
  39. index: 'vuetable',
  40. title: 'Vue表格组件'
  41. }
  42. ]
  43. },
  44. {
  45. index: '3',
  46. title: '表单',
  47. subs: [
  48. {
  49. index: 'baseform',
  50. title: '基本表单'
  51. },
  52. {
  53. index: 'vueeditor',
  54. title: '编辑器'
  55. },
  56. {
  57. index: 'markdown',
  58. title: 'markdown'
  59. },
  60. {
  61. index: 'upload',
  62. title: '文件上传'
  63. }
  64. ]
  65. },
  66. {
  67. index: '4',
  68. title: '图表',
  69. subs: [
  70. {
  71. index: 'basecharts',
  72. title: '基础图表'
  73. },
  74. {
  75. index: 'mixcharts',
  76. title: '混合图表'
  77. }
  78. ]
  79. },
  80. {
  81. index: '5',
  82. title: '系统管理',
  83. subs: [
  84. {
  85. index: 'users',
  86. title: '用户管理'
  87. }
  88. ]
  89. }
  90. ]
  91. }
  92. },
  93. computed:{
  94. onRoutes(){
  95. return this.$route.path.replace('/','');
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .sidebar{
  102. display: block;
  103. position: absolute;
  104. width: 250px;
  105. left: 0;
  106. top: 70px;
  107. bottom:0;
  108. background: #2E363F;
  109. }
  110. .sidebar > ul {
  111. height:100%;
  112. }
  113. </style>