Sidebar.vue 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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">
  8. <i :class="item.icon"></i>{{ item.title }}</template>
  9. <el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">{{ subItem.title }}
  10. </el-menu-item>
  11. </el-submenu>
  12. </template>
  13. <template v-else>
  14. <el-menu-item :index="item.index">
  15. <i :class="item.icon"></i>{{ item.title }}
  16. </el-menu-item>
  17. </template>
  18. </template>
  19. </el-menu>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. items: []
  27. }
  28. },
  29. methods: {
  30. getKey: function(id) {
  31. return 'key_' + id
  32. }
  33. },
  34. computed: {
  35. onRoutes() {
  36. return this.$route.path.replace('/', '')
  37. }
  38. },
  39. mounted: function() {
  40. var items = []
  41. items.push({ icon: '', index: '/manageUser', title: '用户管理'})
  42. items.push({ icon: '', index: '/bannerManage', title: 'Banner管理'})
  43. items.push({ icon: '', index: '/doctorManage', title: '医生管理'})
  44. items.push({ icon: '', index: '/goodsManager', title: '商品管理'})
  45. items.push({ icon: '', index: '/sysLabelManager', title: '商品标签'})
  46. items.push({ icon: '', index: '/equipmentManage', title: '设备管理'})
  47. items.push({ icon: '', index: '/newsManager', title: '新闻管理'})
  48. items.push({ icon: '', index: '/newLabelManager', title: '新闻标签'})
  49. // items.push({ icon: '', index: '/sysConfig', title: '系统配置'})
  50. items.push({ icon: '', index: '/shopConfigAboutUsManage', title: '关于中心'})
  51. items.push({ icon: '', index: '/shopConfigContactUsManage', title: '联系我们'})
  52. items.push({ icon: '', index: '/shopConfigAddressManage', title: '地址定位'})
  53. items.push({ icon: '', index: '/faqManage', title: '常见问题'})
  54. items.push({ icon: '', index: '/exchangeCodeDetail', title: '兑换码查询'})
  55. this.items = items
  56. for (var i in items){
  57. var item = items[i]
  58. if (item.index){
  59. this.$router.push(item.index)
  60. break;
  61. }else{
  62. if (item.subs){
  63. for (var j in item.subs){
  64. var c = item.subs[j]
  65. if (c.index){
  66. this.$router.push(inte.index)
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped>
  76. .sidebar {
  77. display: block;
  78. position: absolute;
  79. width: 250px;
  80. left: 0;
  81. top: 70px;
  82. bottom: 0;
  83. background: #2e363f;
  84. }
  85. .sidebar > ul {
  86. height: 100%;
  87. }
  88. </style>