btnTabs.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view
  3. class="btnTabs"
  4. v-if="list.length > 0"
  5. >
  6. <block v-for="(item, index) in list" :key="item.title">
  7. <view
  8. class="btnTabsItem"
  9. :style="{
  10. 'background-color': '#f9f9f9',
  11. }"
  12. @click="$emit('indexChange', index)"
  13. >
  14. <text
  15. class="tabsText"
  16. :style="{
  17. color: index == value ? '#ff2d55' : '#333333',
  18. }"
  19. >
  20. {{ item.title }}
  21. </text>
  22. </view>
  23. <view
  24. v-if="index != list.length - 1"
  25. :key="index"
  26. class="splitLine"
  27. ></view>
  28. </block>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. /**
  35. * 按钮列表
  36. */
  37. list: {
  38. type: Array,
  39. default: () => [],
  40. },
  41. /**
  42. * 当前选中的按钮索引
  43. */
  44. value: {
  45. type: Number,
  46. default: 0,
  47. },
  48. },
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. .btnTabs {
  53. display: flex;
  54. flex-direction: row;
  55. border-radius: 8rpx;
  56. overflow: hidden;
  57. height: 40rpx;
  58. border: 1px solid rgba(0, 0, 0, 0.05);
  59. .btnTabsItem {
  60. display: flex;
  61. height: 40rpx;
  62. padding: 0 8rpx;
  63. .tabsText {
  64. font-size: 20rpx;
  65. line-height: 40rpx;
  66. height: 40rpx;
  67. }
  68. }
  69. .splitLine {
  70. width: 1px;
  71. height: 40rpx;
  72. background-color: rgba(0, 0, 0, 0.05);
  73. }
  74. }
  75. </style>