index.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="tab_body">
  3. <view class="tab_item" :class="{active: clickIndex == index}" v-for="(item,index) in tabList" :key="index"
  4. @click="tabClick(item,index)">
  5. {{ item.dyh }}
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'tab',
  12. props: {
  13. tabList: {
  14. type: Array,
  15. default: []
  16. }
  17. },
  18. data() {
  19. return {
  20. clickIndex: 0
  21. }
  22. },
  23. methods: {
  24. show() {
  25. if (this.tabList.length > 0) {
  26. this.$emit('tab-click', this.tabList[this.clickIndex])
  27. }
  28. },
  29. tabClick(item, index) {
  30. this.clickIndex = index
  31. this.$emit('tab-click', item)
  32. },
  33. setFirst(index) {
  34. this.clickIndex = index
  35. }
  36. },
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .tab_body {
  41. display: flex;
  42. padding: 0 24rpx;
  43. }
  44. .tab_item {
  45. color: rgba(111, 124, 163, 1);
  46. font-size: 32rpx;
  47. height: 80rpx;
  48. padding: 0 -14rpx;
  49. margin: 0 38rpx 0 14rpx;
  50. }
  51. .active {
  52. color: rgba(4, 8, 20, 0.90) !important;
  53. font-weight: 600;
  54. border-bottom: 8rpx solid rgba(16, 109, 255, 1);
  55. }
  56. </style>