tabTitle.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="tab-title">
  3. <view
  4. v-for="(item, index) in tabList"
  5. :key="index"
  6. class="tab-item"
  7. v-text="item"
  8. :class="index === pickTabIndex ? 'active' : ''"
  9. @click="changeChartsTab(index)"
  10. ></view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'TabTile',
  16. props: {
  17. tabList: {
  18. type: Array,
  19. default: () => {
  20. return []
  21. }
  22. },
  23. active: {
  24. type: Number,
  25. default: 0
  26. }
  27. },
  28. data () {
  29. return {
  30. pickTabIndex: this.active
  31. }
  32. },
  33. watch: {
  34. pickTabIndex: function (val) {
  35. this.$emit('change', val)
  36. }
  37. },
  38. methods: {
  39. changeChartsTab (index) {
  40. this.pickTabIndex = index
  41. }
  42. }
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .tab-title {
  47. display: flex;
  48. height: 82rpx;
  49. line-height: 82rpx;
  50. background-color: #ffffff;
  51. border-bottom: 1px solid #f2f2f2;
  52. .tab-item {
  53. flex: 1;
  54. text-align: center;
  55. font-size: 32rpx;
  56. color: $uni-text-color-grey;
  57. }
  58. .tab-item.active {
  59. color: $j-primary-border-green;
  60. border-bottom: 1px solid $j-primary-border-green;
  61. }
  62. }
  63. </style>