headerSection.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div>
  3. <div class="headerSection">
  4. <div class="header-container width1200">
  5. <router-link :to="{ path: '/' }"
  6. class="logo">
  7. <img src="../assets/images/logo.png"
  8. width="136px"
  9. height="40px"
  10. alt="">
  11. </router-link>
  12. <div class="menu">
  13. <router-link :class="checkActive==1?'active':''"
  14. @click.native="change(1)"
  15. :to="{ path: '/' }">首页</router-link>
  16. <router-link :class="checkActive==2?'active':''"
  17. @click.native="change(2)"
  18. :to="{ path: '/project' }">产品</router-link>
  19. <router-link :class="checkActive==3?'active':''"
  20. @click.native="change(3)"
  21. :to="{ path: '/consult' }">咨询</router-link>
  22. <router-link :class="checkActive==4?'active':''"
  23. @click.native="change(4)"
  24. :to="{ path: '/aboutUs' }">关于我们</router-link>
  25. <div class="bandBtn">合作机构</div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="wall"></div>
  30. </div>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'headerSection',
  35. props: ['name'],
  36. data () {
  37. return {
  38. checkActive: 1
  39. }
  40. },
  41. mounted () {
  42. let url = this.$route
  43. console.log(url)
  44. switch (url.path) {
  45. case '/': {
  46. this.change(1)
  47. break
  48. }
  49. case '/project': {
  50. this.change(2)
  51. break
  52. }
  53. case '/consult': {
  54. this.change(3)
  55. break
  56. }
  57. case '/aboutUs': {
  58. this.change(4)
  59. break
  60. }
  61. }
  62. },
  63. methods: {
  64. change (num) {
  65. this.checkActive = num;
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="less" scoped>
  71. .bandBtn {
  72. width: 112px;
  73. height: 30px;
  74. background: #2dc7aa;
  75. border-radius: 4px;
  76. color: #fff;
  77. margin-left: 70px;
  78. line-height: 30px;
  79. cursor: pointer;
  80. position: relative;
  81. top: 8px;
  82. }
  83. .wall {
  84. height: 82px;
  85. }
  86. .headerSection {
  87. background-color: #fff;
  88. position: fixed;
  89. width: 100%;
  90. top: 0px;
  91. z-index: 1000;
  92. .header-container {
  93. margin: 0 auto;
  94. // overflow: hidden;
  95. display: flex;
  96. flex-direction: row;
  97. justify-content: space-between;
  98. height: 80px;
  99. padding-top: 17px;
  100. }
  101. .logo {
  102. // float: left;
  103. width: 159px;
  104. height: 48px;
  105. }
  106. .menu {
  107. display: flex;
  108. flex-direction: row;
  109. font-size: 16px;
  110. a {
  111. margin-left: 80px;
  112. color: #565757;
  113. line-height: 48px;
  114. text-decoration: none;
  115. position: relative;
  116. // display: block;
  117. text-decoration: none;
  118. text-transform: uppercase;
  119. transition: 0.5s;
  120. &::after {
  121. position: absolute;
  122. content: "";
  123. top: 60%;
  124. left: 0;
  125. width: 100%;
  126. height: 3px;
  127. background-color: #000;
  128. z-index: 100;
  129. transform: scaleX(0);
  130. transform-origin: right;
  131. transition: transform 0.5s;
  132. }
  133. &:hover,
  134. &.hover {
  135. color: #000000;
  136. font-weight: 600;
  137. }
  138. &:hover::after {
  139. transform: scaleX(1);
  140. transform-origin: left;
  141. }
  142. }
  143. }
  144. a.active {
  145. color: #000 !important;
  146. font-weight: 600;
  147. &::after {
  148. position: absolute;
  149. content: "";
  150. top: 60%;
  151. left: 0;
  152. width: 100%;
  153. height: 3px;
  154. background-color: #000;
  155. z-index: 100;
  156. transform: scaleX(1);
  157. transform-origin: left;
  158. }
  159. }
  160. }
  161. </style>