index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="tabbar">
  3. <div class="tab">
  4. <div
  5. class="item"
  6. :class="{ active: current === item.id }"
  7. v-for="item in tabs"
  8. :key="item.id"
  9. v-text="item.name"
  10. @click="$emit('change', item)"
  11. ></div>
  12. </div>
  13. <div class="tab-search">
  14. <input
  15. type="text"
  16. class="control"
  17. placeholder="搜索名称"
  18. @keyup.enter="($event) => $emit('search', $event.target.value)"
  19. />
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'SimpleTabs',
  26. props: {
  27. tabs: {
  28. type: Array,
  29. default: () => [],
  30. },
  31. current: {
  32. type: Number,
  33. default: 0,
  34. },
  35. },
  36. }
  37. </script>
  38. <style scoped lang="scss">
  39. @media screen and (min-width: 768px) {
  40. .tabbar {
  41. @include useTheme() {
  42. display: flex;
  43. justify-content: space-between;
  44. align-items: center;
  45. margin-right: 24px;
  46. .tab-search {
  47. position: relative;
  48. width: 430px;
  49. height: 40px;
  50. border: 1px solid #d8d8d8;
  51. border-radius: 4px;
  52. padding: 0 16px;
  53. padding-left: 46px;
  54. &::after {
  55. position: absolute;
  56. top: 4px;
  57. left: 8px;
  58. content: '';
  59. width: 30px;
  60. height: 30px;
  61. background: url(~assets/theme-images/common/pc-icon-search.png)
  62. no-repeat center;
  63. background-size: 30px;
  64. }
  65. .control {
  66. width: 100%;
  67. height: 36px;
  68. display: block;
  69. border: 0;
  70. outline: none;
  71. line-height: 36px;
  72. background: #fff;
  73. }
  74. }
  75. .tab {
  76. overflow-x: auto;
  77. white-space: nowrap;
  78. height: 64px;
  79. &::-webkit-scrollbar {
  80. display: none;
  81. }
  82. .item {
  83. position: relative;
  84. display: inline-block;
  85. font-size: 20px;
  86. line-height: 64px;
  87. color: #101010;
  88. padding: 0 32px;
  89. cursor: pointer;
  90. &::after {
  91. position: absolute;
  92. content: '';
  93. width: 40px;
  94. height: 2px;
  95. background-color: #fff;
  96. bottom: 0;
  97. left: 50%;
  98. transform: translateX(-50%);
  99. }
  100. &.active {
  101. color: fetch('color');
  102. &::after {
  103. background-color: fetch('color');
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. }
  111. @media screen and (max-width: 768px) {
  112. .tabbar {
  113. @include useTheme() {
  114. .tab-search {
  115. display: none;
  116. }
  117. .tab {
  118. overflow-x: auto;
  119. white-space: nowrap;
  120. padding-top: 4vw;
  121. &::-webkit-scrollbar {
  122. display: none;
  123. }
  124. .item {
  125. position: relative;
  126. display: inline-block;
  127. font-size: 4.2vw;
  128. line-height: 8vw;
  129. color: #101010;
  130. padding: 0 6vw;
  131. padding-bottom: 1.2vw;
  132. &::after {
  133. position: absolute;
  134. content: '';
  135. width: 8vw;
  136. height: 0.4vw;
  137. background-color: #fff;
  138. bottom: 0;
  139. left: 50%;
  140. transform: translateX(-50%);
  141. }
  142. &.active {
  143. font-size: 4.6vw;
  144. color: fetch('color');
  145. &::after {
  146. background-color: fetch('color');
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. </style>