TopTabs2.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="tb" :style="{'top':top+'px'}">
  3. <view class="tabs">
  4. <view v-for="(item,index) in list" :key="index" @tap="changeTab(index)">
  5. <text :class="index==current?'active':''">{{item.name}}</text>
  6. </view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'topTabs',
  13. props: {
  14. list: {
  15. typeof: Array,
  16. default: []
  17. },
  18. top: {
  19. typeof: Number,
  20. default: 0
  21. },
  22. placeholder: {
  23. typeof: String,
  24. default: ""
  25. },
  26. showSearch: {
  27. typeof: Boolean,
  28. default: true
  29. }
  30. },
  31. data() {
  32. return {
  33. current: 0,
  34. mysearch: ''
  35. }
  36. },
  37. methods: {
  38. sousuo() {
  39. this.$emit('sousuo', this.mysearch);
  40. },
  41. changeTab(index) {
  42. this.current = index;
  43. this.$emit('changeTab', index);
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="less">
  49. .tb {
  50. width: 100%;
  51. position: fixed;
  52. top: 0;
  53. left: 0;
  54. z-index: 999;
  55. .searchBoxParent {
  56. width: 100%;
  57. background: #fff;
  58. padding: 20rpx 24rpx 6rpx;
  59. box-sizing: border-box;
  60. .searchBox {
  61. width: 100%;
  62. background-color: #fff;
  63. }
  64. }
  65. .tabs {
  66. background: #fff;
  67. padding: 26rpx 0;
  68. display: flex;
  69. align-items: center;
  70. width: 100%;
  71. &>view {
  72. width: 50%;
  73. font-size: 28rpx;
  74. font-family: PingFangSC-Regular, PingFang SC;
  75. font-weight: 400;
  76. color: #777777;
  77. line-height: 40rpx;
  78. position: relative;
  79. text-align: center;
  80. }
  81. .active {
  82. font-size: 32rpx;
  83. font-family: PingFang-SC-Bold, PingFang-SC;
  84. font-weight: bold;
  85. color: #0DBFFD;
  86. line-height: 45rpx;
  87. }
  88. .active::after {
  89. position: absolute;
  90. content: '';
  91. width: 84rpx;
  92. height: 8rpx;
  93. background: #0DBFFD;
  94. bottom: -26rpx;
  95. left: 50%;
  96. margin-left: -42rpx;
  97. }
  98. }
  99. }
  100. </style>