side-nav.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <style>
  2. .side-nav {
  3. width: 100%;
  4. box-sizing: border-box;
  5. border-right: 1px solid #eaeefa;
  6. li {
  7. list-style: none;
  8. }
  9. ul {
  10. padding: 0;
  11. margin: 0;
  12. overflow: hidden;
  13. }
  14. .nav-item {
  15. a {
  16. font-size:18px;
  17. color:#5e6d82;
  18. line-height: 42px;
  19. height: 42px;
  20. margin: 0;
  21. padding: 0 0 0 12px;
  22. text-decoration: none;
  23. display: block;
  24. position: relative;
  25. transition: all .3s;
  26. &.active {
  27. color: #20a0ff;
  28. &:after {
  29. content: '';
  30. width: 2px;
  31. background-color: #20a0ff;
  32. height: 32px;
  33. border-radius: 2px;
  34. left: 0;
  35. position: absolute;
  36. top: 5px;
  37. }
  38. }
  39. }
  40. .nav-item {
  41. a {
  42. display: block;
  43. height: 42px;
  44. line-height: 42px;
  45. font-size: 14px;
  46. padding-left: 22px;
  47. &:hover {
  48. color: #20a0ff;
  49. }
  50. }
  51. }
  52. }
  53. .nav-group__title {
  54. color: #99a9bf;
  55. padding-left: 15px;
  56. line-height: 34px;
  57. }
  58. }
  59. </style>
  60. <template>
  61. <div class="side-nav">
  62. <ul>
  63. <li class="nav-item" v-for="item in data">
  64. <a v-if="!item.path">{{item.name}}</a>
  65. <router-link
  66. v-else
  67. active-class="active"
  68. :to="base + item.path"
  69. exact
  70. v-text="item.title || item.name">
  71. </router-link>
  72. <ul class="pure-menu-list sub-nav" v-if="item.children">
  73. <li class="nav-item" v-for="navItem in item.children">
  74. <router-link
  75. class=""
  76. active-class="active"
  77. :to="base + navItem.path"
  78. exact
  79. v-text="navItem.title || navItem.name">
  80. </router-link>
  81. </li>
  82. </ul>
  83. <template v-if="item.groups">
  84. <div class="nav-group" v-for="group in item.groups">
  85. <div class="nav-group__title">{{group.groupName}}</div>
  86. <ul class="pure-menu-list">
  87. <li
  88. class="nav-item"
  89. v-for="navItem in group.list"
  90. v-if="!navItem.disabled">
  91. <router-link
  92. active-class="active"
  93. :to="base + navItem.path"
  94. exact
  95. v-text="navItem.title"></router-link>
  96. </li>
  97. </ul>
  98. </div>
  99. </template>
  100. </li>
  101. </ul>
  102. </div>
  103. </template>
  104. <script>
  105. export default {
  106. props: {
  107. data: Array,
  108. base: {
  109. type: String,
  110. default: ''
  111. }
  112. },
  113. data() {
  114. return {
  115. highlights: [],
  116. navState: []
  117. };
  118. }
  119. };
  120. </script>