TopTabs1.vue 2.1 KB

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