Header.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="header">
  3. <div class="logo center">
  4. <img src="@/assets/logo.png" alt="" />
  5. <span>飞鸟有味</span>
  6. </div>
  7. <div class="center-menu">
  8. <div class="tabs center">
  9. <div
  10. :class="['tab-item center', { active: index === active }]"
  11. @click="handleActive(item, index)"
  12. v-for="(item, index) in tabs"
  13. :key="index"
  14. >
  15. {{ item.name }}
  16. </div>
  17. </div>
  18. </div>
  19. <div class="header-btn">我要认证</div>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { ref, defineEmits } from "vue";
  24. const active = ref(0);
  25. const tabs = [
  26. {
  27. name: "首页",
  28. component: "Home",
  29. },
  30. {
  31. name: "飞鸟三味",
  32. component: "ThreeFlavors",
  33. },
  34. {
  35. name: "3体6维认证",
  36. component: "Certification",
  37. },
  38. {
  39. name: "飞鸟溯源",
  40. component: "TraceSource",
  41. },
  42. {
  43. name: "生态守护者联盟",
  44. component: "DefendLeague",
  45. },
  46. {
  47. name: "有味指数地图",
  48. component: "ExponentialMap",
  49. },
  50. ];
  51. const emit = defineEmits(["handleActive"]);
  52. const handleActive = (value, index) => {
  53. active.value = index;
  54. emit("handleActive", value.component);
  55. };
  56. const input = ref("");
  57. </script>
  58. <style lang="scss" scoped>
  59. .header {
  60. width: 100%;
  61. height: 70px;
  62. box-sizing: border-box;
  63. background: rgba(0, 0, 0, 0.34);
  64. backdrop-filter: blur(20px);
  65. display: flex;
  66. align-items: center;
  67. color: #fff;
  68. position: fixed;
  69. top: 0;
  70. left: 0;
  71. z-index: 2;
  72. .center {
  73. display: flex;
  74. align-items: center;
  75. }
  76. .logo {
  77. font-size: 24px;
  78. font-weight: 400;
  79. letter-spacing: 2px;
  80. position: relative;
  81. z-index: 2;
  82. color: #FFDA75;
  83. // margin-right: 70px;
  84. img {
  85. width: 30px;
  86. height: 30px;
  87. margin: 0 20px 0 30px;
  88. }
  89. span {
  90. // font-family: "PangMenZhengDao";
  91. }
  92. }
  93. .center-menu {
  94. height: 100%;
  95. position: relative;
  96. flex: 1;
  97. // width: calc(100% - 500px);
  98. }
  99. .tabs {
  100. // width: 100%;
  101. height: 100%;
  102. position: absolute;
  103. left: 384px;
  104. // left: 20%;
  105. // transform: translateX(-50%);
  106. z-index: 2;
  107. margin-right: 30px;
  108. .tab-item {
  109. font-weight: 400;
  110. font-size: 18px;
  111. // width: 110px;
  112. height: 100%;
  113. justify-content: center;
  114. text-align: center;
  115. margin-right: 70px;
  116. cursor: pointer;
  117. position: relative;
  118. transform: perspective(1px) translateZ(0);
  119. overflow: hidden;
  120. // font-family: "PangMenZhengDao";
  121. &::before {
  122. content: "";
  123. position: absolute;
  124. z-index: -1;
  125. // left: 100%;
  126. left: -100%;
  127. // right: 51%;
  128. bottom: 0;
  129. width: 100%;
  130. background: #ffda75;
  131. border-radius: 20px;
  132. height: 4px;
  133. transition-property: left, right;
  134. transition-duration: 0.3s;
  135. transition-timing-function: ease-out;
  136. opacity: 0;
  137. }
  138. &.active {
  139. font-weight: bold;
  140. color: #ffda75;
  141. &::before {
  142. left: 0;
  143. right: 0;
  144. opacity: 1;
  145. }
  146. }
  147. }
  148. }
  149. .header-btn {
  150. margin-right: 71px;
  151. font-size: 18px;
  152. color: #FFDA75;
  153. padding: 10px 20px;
  154. border-radius: 5px;
  155. background: rgba(255, 218, 117, 0.08);
  156. border: 1px solid #FFDA75;
  157. }
  158. }
  159. </style>