北京博音润迪官网

home-meun1.vue 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="common-layout">
  3. <el-container>
  4. <el-header>
  5. <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
  6. <div class="flex-grow"></div>
  7. <!-- <template v-for="(item, index) in menus">
  8. <el-menu-item>{{ item.meta.title }}</el-menu-item>
  9. </template> -->
  10. <el-menu-item v-bind:key="index" :index="index" v-for="(item, index) in menus">
  11. {{ item.meta.title }}
  12. <!-- <template v-if="item.meta.title === '产品介绍'">
  13. {{ item.meta.title }}
  14. <el-dropdown>
  15. <span class="el-dropdown-link">
  16. 产品介绍
  17. <el-icon class="el-icon--right">
  18. <arrow-down />
  19. </el-icon>
  20. </span>
  21. <template #dropdown>
  22. <el-dropdown-menu>
  23. <el-dropdown-item>Action 1</el-dropdown-item>
  24. <el-dropdown-item>Action 2</el-dropdown-item>
  25. <el-dropdown-item>Action 3</el-dropdown-item>
  26. <el-dropdown-item disabled>Action 4</el-dropdown-item>
  27. <el-dropdown-item divided>Action 5</el-dropdown-item>
  28. </el-dropdown-menu>
  29. </template>
  30. </el-dropdown>
  31. </template>
  32. <template v-else>
  33. {{ item.meta.title }}
  34. </template> -->
  35. </el-menu-item>
  36. </el-menu>
  37. </el-header>
  38. <el-main>
  39. <el-scrollbar style="margin-top: 20px;">
  40. <router-view />
  41. </el-scrollbar>
  42. </el-main>
  43. </el-container>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { ref } from 'vue'
  48. import routers from "../../router";
  49. import { useRouter } from "vue-router";
  50. import { ArrowDown } from '@element-plus/icons-vue'
  51. const menus = routers.options.routes.find((o) => { return o.name === 'home'; }).children;
  52. const router = useRouter();
  53. console.log(router.currentRoute.value.path, 'router');
  54. const index = menus.findIndex((o) => { return o.path === router.currentRoute.value.path });
  55. const activeIndex = ref(index)
  56. const handleSelect = (key, keyPath) => {
  57. console.log(key, keyPath)
  58. activeIndex.value = Number(key);
  59. console.log(menus[key])
  60. router.push(menus[key])
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. :deep(.el-menu ){
  65. background:none;
  66. border: none !important;
  67. }
  68. :deep(.el-menu--horizontal>.el-menu-item.is-active ) {
  69. color: #fff !important;
  70. border: none;
  71. }
  72. :deep(.el-menu-item:not(.is-disabled):hover){
  73. background: none !important;
  74. }
  75. :deep(.el-menu-item:not(.is-disabled):focus){
  76. background-color:rgba(220,38,38,0) !important;
  77. }
  78. :deep(.el-menu-item){
  79. font-size: 26px;
  80. font-weight: bold;
  81. }
  82. :deep(.el-dropdown-link){
  83. font-size: 22px;
  84. color: inherit;
  85. }
  86. .flex-grow {
  87. flex-grow: 0.8;
  88. }
  89. </style>