mainLeft.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div id="mainLeft">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-menu :default-active="path" class="el-menu-vertical-demo" :router="true">
  6. <template v-for="(item, index) in subMenu">
  7. <template v-if="item.children&&item.children.length>0">
  8. <template v-for="(sec) in item.children">
  9. <el-menu-item :index="sec.path" :key="sec.id" v-if="sec.type !== 'url'">{{ sec.title }}</el-menu-item>
  10. <el-menu-item :index="``" :key="sec.id" @click="turnTo(sec.url)" v-else> {{ sec.title }}</el-menu-item>
  11. </template>
  12. </template>
  13. <el-menu-item :index="item.path" :key="index" v-else-if="item.type === 'content'||item.type==='column'">{{ item.title }}</el-menu-item>
  14. <el-menu-item :index="`${index}-${subIndex}`" :key="index" @click="turnTo(item.url)" v-else> {{ item.title }}</el-menu-item>
  15. </template>
  16. </el-menu>
  17. </el-col>
  18. </el-row>
  19. </div>
  20. </template>
  21. <script>
  22. import { mapActions, mapState,mapMutations } from 'vuex';
  23. export default {
  24. name: 'mainLeft',
  25. props: {},
  26. components: {},
  27. data: () => ({}),
  28. created() {this.getSubMenu()},
  29. watch:{
  30. path: 'getSubMenu',
  31. },
  32. computed: {
  33. ...mapState(['subMenu']),
  34. path(){
  35. return this.$route.path;
  36. },
  37. },
  38. methods: {
  39. ...mapMutations(['setSubMenu']),
  40. getSubMenu(){
  41. this.setSubMenu(this.path);
  42. },
  43. },
  44. };
  45. </script>
  46. <style lang="less" scoped>
  47. .info {
  48. height: 44px;
  49. line-height: 44px;
  50. padding: 0 15px;
  51. }
  52. .info .title {
  53. border-bottom: 1px dashed #ccc;
  54. display: inline-block;
  55. height: 40px;
  56. width: 260px;
  57. padding: 0 0px;
  58. }
  59. </style>