KdTabs.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="kd-tabs-container">
  3. <view
  4. class="tab-item"
  5. @click="tabClick(item, index)"
  6. :class="{ active: active === index }"
  7. v-for="(item, index) in list"
  8. :key="index"
  9. >
  10. {{ item }}
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. model: {
  17. prop: 'active',
  18. event: 'change'
  19. },
  20. props: {
  21. list: {
  22. type: Array,
  23. default: () => []
  24. },
  25. active: {
  26. type: Number,
  27. default: 0
  28. }
  29. },
  30. methods: {
  31. tabClick (item, index) {
  32. this.$emit('change', index)
  33. }
  34. }
  35. }
  36. </script>
  37. <style lang="scss" scoped>
  38. .kd-tabs-container {
  39. display: flex;
  40. justify-content: flex-start;
  41. align-items: center;
  42. // border-bottom: 1rpx solid rgb(215 215 215);
  43. border-bottom: 1rpx solid #d7d7d7;
  44. .tab-item {
  45. height: 50rpx;
  46. padding: 0 30rpx;
  47. line-height: 50rpx;
  48. text-align: center;
  49. font-size: 32rpx;
  50. background-color: rgba(242, 242, 242, 1);
  51. color: #333;
  52. border-top: 1rpx solid rgba(242, 242, 242, 1);
  53. border-radius: 4rpx;
  54. margin-left: 8rpx;
  55. &.active {
  56. color: $j-primary-border-green;
  57. border-color: $j-primary-border-green;
  58. }
  59. }
  60. }
  61. </style>