task-tabs.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="task-tabs">
  3. <view class="task-tabs__item" :class="{active:item.id===currentIndex}" v-for="item in tabList" :key="item.id"
  4. @click="handleTabClick(item)">
  5. {{item.name}}
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. currentIndex: 1,
  14. tabList: [{
  15. id: 1,
  16. name: '签到记录',
  17. }, {
  18. id: 2,
  19. name: '诱捕器',
  20. }, {
  21. id: 3,
  22. name: '行驶轨迹'
  23. }]
  24. };
  25. },
  26. methods: {
  27. handleTabClick(tabItem) {
  28. if (!tabItem.id) {
  29. return
  30. }
  31. this.currentIndex = tabItem.id
  32. this.$emit('tabClick',tabItem.id)
  33. },
  34. }
  35. }
  36. </script>
  37. <style lang="scss" scoped>
  38. .task-tabs {
  39. position: relative;
  40. display: flex;
  41. align-items: center;
  42. justify-content: space-between;
  43. padding: 0 14rpx;
  44. &::before {
  45. content: '';
  46. left: 4rpx;
  47. right: 4rpx;
  48. bottom: 0;
  49. @include hairline-bottom(rgba(151, 151, 151, 0.09));
  50. position: absolute;
  51. }
  52. &__item {
  53. position: relative;
  54. width: 200rpx;
  55. height: 60rpx;
  56. font-weight: 400;
  57. text-align: center;
  58. font-size: 14px;
  59. line-height: 60rpx;
  60. color: #7489A9;
  61. border-radius: 8rpx;
  62. background: #F4F7FC;
  63. transition: all 1s;
  64. &::before {
  65. content: '';
  66. position: absolute;
  67. width: 0;
  68. height: 0;
  69. left: 50%;
  70. bottom: -22rpx;
  71. transform: translateX(-50%);
  72. border: 12rpx solid transparent;
  73. transition: border-top-color 1s;
  74. }
  75. &::after {
  76. content: '';
  77. position: absolute;
  78. width: 0rpx;
  79. height: 4rpx;
  80. left: 50%;
  81. bottom: -12rpx;
  82. transform: translateX(-50%);
  83. // background-color: transparent;
  84. background-color: #1B76FF;
  85. transition: width 1s;
  86. }
  87. &.active {
  88. color: #fff;
  89. font-weight: 500;
  90. background: #1B76FF;
  91. &::before {
  92. border-top-color: #1B76FF;
  93. }
  94. &::after {
  95. width: 120rpx;
  96. // background-color: #1B76FF;
  97. }
  98. }
  99. }
  100. }
  101. </style>