index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. display: flex;
  42. justify-content: space-between;
  43. align-items: center;
  44. margin-right: 24px;
  45. .tab-search {
  46. position: relative;
  47. width: 430px;
  48. height: 40px;
  49. border: 1px solid #d8d8d8;
  50. border-radius: 4px;
  51. padding: 0 16px;
  52. padding-left: 46px;
  53. &::after {
  54. position: absolute;
  55. top: 4px;
  56. left: 8px;
  57. content: '';
  58. width: 30px;
  59. height: 30px;
  60. background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
  61. no-repeat center;
  62. background-size: 30px;
  63. }
  64. .control {
  65. width: 100%;
  66. height: 36px;
  67. display: block;
  68. border: 0;
  69. outline: none;
  70. line-height: 36px;
  71. background: #fff;
  72. }
  73. }
  74. .tab {
  75. overflow-x: auto;
  76. white-space: nowrap;
  77. height: 64px;
  78. &::-webkit-scrollbar {
  79. display: none;
  80. }
  81. .item {
  82. position: relative;
  83. display: inline-block;
  84. font-size: 20px;
  85. line-height: 64px;
  86. color: #101010;
  87. padding: 0 32px;
  88. cursor: pointer;
  89. &::after {
  90. position: absolute;
  91. content: '';
  92. width: 40px;
  93. height: 2px;
  94. background-color: #fff;
  95. bottom: 0;
  96. left: 50%;
  97. transform: translateX(-50%);
  98. }
  99. &.active {
  100. color: #bc1724;
  101. &::after {
  102. background-color: #bc1724;
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. @media screen and (max-width: 768px) {
  110. .tabbar {
  111. .tab-search {
  112. display: none;
  113. }
  114. .tab {
  115. overflow-x: auto;
  116. white-space: nowrap;
  117. padding-top: 4vw;
  118. &::-webkit-scrollbar {
  119. display: none;
  120. }
  121. .item {
  122. position: relative;
  123. display: inline-block;
  124. font-size: 4.2vw;
  125. line-height: 8vw;
  126. color: #101010;
  127. padding: 0 6vw;
  128. padding-bottom: 1.2vw;
  129. &::after {
  130. position: absolute;
  131. content: '';
  132. width: 8vw;
  133. height: 0.4vw;
  134. background-color: #fff;
  135. bottom: 0;
  136. left: 50%;
  137. transform: translateX(-50%);
  138. }
  139. &.active {
  140. font-size: 4.6vw;
  141. color: #bc1724;
  142. &::after {
  143. background-color: #bc1724;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. </style>