nav1.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="home-nav">
  3. <el-menu
  4. :default-active="activeMenu"
  5. :collapse="isCollapse"
  6. :text-color="variables.menuText"
  7. :unique-opened="false"
  8. :active-text-color="variables.menuActiveText"
  9. mode="horizontal"
  10. >
  11. <sidebar-item
  12. v-for="route in routes"
  13. :key="route.path"
  14. :item="route"
  15. :base-path="route.path"
  16. />
  17. </el-menu>
  18. </div>
  19. </template>
  20. <script>
  21. import SidebarItem from "./SidebarItem2";
  22. import { mapGetters } from "vuex";
  23. import variables from "@/styles/variables.scss";
  24. export default {
  25. name: "nav1",
  26. components: {
  27. SidebarItem,
  28. },
  29. data() {
  30. return {};
  31. },
  32. computed: {
  33. ...mapGetters(["sidebar"]),
  34. routes() {
  35. return this.$router.options.routes;
  36. },
  37. activeMenu() {
  38. const route = this.$route;
  39. const { meta, path } = route;
  40. // if set path, the sidebar will highlight the path you set
  41. if (meta.activeMenu) {
  42. return meta.activeMenu;
  43. }
  44. return path;
  45. },
  46. variables() {
  47. return variables;
  48. },
  49. isCollapse() {
  50. return !this.sidebar.opened;
  51. },
  52. },
  53. };
  54. </script>
  55. <style lang="scss">
  56. .home-nav {
  57. left: 1rem;
  58. display: inline-block;
  59. position: absolute;
  60. .el-menu-item:focus,
  61. .el-menu-item:hover {
  62. background: rgba(0, 0, 0, 0);
  63. }
  64. .el-submenu__title:hover {
  65. background: rgba(0, 0, 0, 0);
  66. span {
  67. color: rgb(92, 136, 250);
  68. text-align: center;
  69. }
  70. // i{
  71. // color:rgb(92, 136, 250)
  72. // }
  73. }
  74. .el-menu.el-menu--horizontal {
  75. border-bottom: 0;
  76. background: rgba(0, 0, 0, 0);
  77. // border:1px solid pink;
  78. z-index: 1000;
  79. // line-height:3.5rem;
  80. line-height: 2.5rem;
  81. .el-menu-item,
  82. .el-submenu__title {
  83. height: 3.5rem;
  84. line-height: 3.5rem;
  85. font-size: 1.8rem;
  86. span {
  87. color: #fff;
  88. }
  89. }
  90. .el-submenu__title {
  91. padding: 0 2rem;
  92. .el-submenu__icon-arrow {
  93. display: none;
  94. }
  95. }
  96. }
  97. .el-menu > div {
  98. display: inline-block;
  99. }
  100. }
  101. </style>
  102. <style lang="scss">
  103. .el-menu--horizontal .el-menu .el-menu-item,
  104. .el-menu--horizontal .el-menu .el-submenu__title {
  105. background: #021132;
  106. text-align: center;
  107. }
  108. .el-menu--horizontal .el-menu--popup {
  109. min-width: 12rem !important;
  110. padding: 0;
  111. .el-menu-item {
  112. font-size: 1.7rem;
  113. // color:#000!important;
  114. }
  115. .el-menu-item:hover {
  116. span {
  117. color: rgb(92, 136, 250);
  118. }
  119. }
  120. }
  121. </style>