task-tabs.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. &::before {
  53. content: '';
  54. left: 4rpx;
  55. right: 4rpx;
  56. bottom: 0;
  57. @include hairline-bottom(rgba(151, 151, 151, 0.09));
  58. position: absolute;
  59. }
  60. &__item {
  61. position: relative;
  62. flex: 1 1 auto;
  63. height: 60rpx;
  64. font-weight: 400;
  65. text-align: center;
  66. font-size: 14px;
  67. line-height: 60rpx;
  68. margin-left: 80rpx;
  69. color: #7489A9;
  70. border-radius: 8rpx;
  71. background: #F4F7FC;
  72. transition: all 1s;
  73. &::before {
  74. content: '';
  75. position: absolute;
  76. width: 0;
  77. height: 0;
  78. left: 50%;
  79. bottom: -22rpx;
  80. transform: translateX(-50%);
  81. border: 12rpx solid transparent;
  82. transition: border-top-color 1s;
  83. }
  84. &::after {
  85. content: '';
  86. position: absolute;
  87. width: 0rpx;
  88. height: 4rpx;
  89. left: 50%;
  90. bottom: -12rpx;
  91. transform: translateX(-50%);
  92. // background-color: transparent;
  93. background-color: #1B76FF;
  94. transition: width 1s;
  95. }
  96. &.active {
  97. color: #fff;
  98. font-weight: 500;
  99. background: #1B76FF;
  100. &::before {
  101. border-top-color: #1B76FF;
  102. }
  103. &::after {
  104. width: 120rpx;
  105. // background-color: #1B76FF;
  106. }
  107. }
  108. }
  109. }
  110. </style>