topTabs.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="tb">
  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. top: 0;
  59. left: 0;
  60. z-index: 999;
  61. .searchBoxParent {
  62. width: 100%;
  63. background: #fff;
  64. padding: 20rpx 24rpx 6rpx;
  65. box-sizing: border-box;
  66. .searchBox {
  67. width: 100%;
  68. background-color: #fff;
  69. }
  70. }
  71. .tabs {
  72. background: #fff;
  73. padding: 26rpx 0;
  74. display: flex;
  75. align-items: center;
  76. width: 100%;
  77. &>view {
  78. width: 25%;
  79. font-size: 28rpx;
  80. font-family: PingFangSC-Regular, PingFang SC;
  81. font-weight: 400;
  82. color: black;
  83. line-height: 40rpx;
  84. position: relative;
  85. text-align: center;
  86. }
  87. .active {
  88. font-size: 32rpx;
  89. font-family: PingFang-SC-Bold, PingFang-SC;
  90. font-weight: bold;
  91. color: black;
  92. line-height: 45rpx;
  93. }
  94. .active::after {
  95. position: absolute;
  96. content: '';
  97. width: 50rpx;
  98. height: 8rpx;
  99. background: #1372FF;
  100. bottom: -26rpx;
  101. left: 60%;
  102. margin-left: -42rpx;
  103. }
  104. }
  105. }
  106. </style>