header.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="header">
  3. <div class="con">
  4. <a href="https://www.4dkankan.com/" class="logo">
  5. <img :src="require('@/assets/images/icons/logo_black.svg')" alt="" />
  6. </a>
  7. <ul class="tab">
  8. <li @click="handleItem(item)" :class="{active:active.id==item.id}" v-for="(item, i) in tab" :key="i">
  9. {{ item.name }}
  10. </li>
  11. </ul>
  12. <user-info class="user-info"></user-info>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import UserInfo from "@/components/userInfo.vue";
  18. export default {
  19. components: {
  20. UserInfo,
  21. },
  22. data() {
  23. return {
  24. active:{},
  25. tab: [
  26. {
  27. name: "我的作品",
  28. id: "works",
  29. path:{
  30. path:'/works'
  31. }
  32. },
  33. {
  34. name: "我的素材",
  35. id: "material",
  36. path:{
  37. path:'/'
  38. }
  39. }
  40. ],
  41. };
  42. },
  43. watch:{
  44. '$route.meta':{
  45. deep:true,
  46. handler:function (newVal) {
  47. this.active = this.tab.find(item=>{
  48. return item.id == newVal.belong
  49. })
  50. }
  51. }
  52. },
  53. methods:{
  54. handleItem(item){
  55. this.$router.push(item.path)
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="less" scoped>
  61. .header {
  62. width: 100%;
  63. background: #fff;
  64. position: fixed;
  65. top: 0;
  66. left: 0;
  67. z-index: 999;
  68. .con {
  69. color: #000;
  70. max-width: 1280px;
  71. height: 70px;
  72. display: flex;
  73. align-items: center;
  74. margin: 0 auto;
  75. position: relative;
  76. padding: 0;
  77. .logo {
  78. font-size: 24px;
  79. font-weight: bold;
  80. height: 100%;
  81. >img{
  82. height: 100%;
  83. vertical-align: middle;
  84. }
  85. }
  86. .tab {
  87. display: flex;
  88. align-items: center;
  89. margin-left: 116px;
  90. > li {
  91. cursor: pointer;
  92. margin-right: 50px;
  93. text-align: left;
  94. font-size: 16px;
  95. color: #909090;
  96. &.active{
  97. font-size: 16px;
  98. font-weight: bold;
  99. color: #0076F6;
  100. position: relative;
  101. &::before{
  102. content: '';
  103. width: 20px;
  104. height: 2px;
  105. background: #0076F6;
  106. display: inline-block;
  107. position: absolute;
  108. left: 50%;
  109. transform: translateX(-50%);
  110. bottom: -10px;
  111. }
  112. }
  113. }
  114. }
  115. .user-info {
  116. margin-left: auto;
  117. margin-right: 0;
  118. }
  119. }
  120. }
  121. </style>