Sidebar.vue 3.8 KB

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