task-tabs.vue 2.1 KB

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