tabs.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="slot" :style="{ padding, backgroundColor }">
  3. <u-tabs
  4. name="text"
  5. :list="listData"
  6. :is-scroll="true"
  7. :active-color="activeColor || default_activeColor"
  8. :inactive-color="inactiveColor || default_inactiveColor"
  9. :font-size="fontSize"
  10. :current="current"
  11. @change="change"
  12. :bar-style="{ backgrond: activeBarColor || default_activeBarColor }"
  13. bg-color="#FAFAFA"
  14. bar-height="6"
  15. :bg-color="backgroundColor"
  16. :item-width="itemWidth"
  17. ></u-tabs>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'tabs',
  23. data() {
  24. return {
  25. current: 0,
  26. default_activeBarColor: this.$appTheme.appThemeColor,
  27. default_activeColor: this.$appTheme.appThemeTextBlackColor,
  28. default_inactiveColor: this.$appTheme.appThemeTextBlackColor
  29. };
  30. },
  31. props: {
  32. // 配置项
  33. listData: {
  34. type: Array,
  35. default: () => {
  36. return [];
  37. }
  38. },
  39. // 激活颜色
  40. activeBarColor: {
  41. type: String,
  42. default: null
  43. },
  44. activeColor: {
  45. type: String,
  46. default: null
  47. },
  48. inactiveColor: {
  49. type: String,
  50. default: null
  51. },
  52. // 内边距
  53. padding: {
  54. type: String,
  55. default: '0 0rpx 20rpx'
  56. },
  57. // 背景色
  58. backgroundColor: {
  59. type: String,
  60. default: '#fafafa'
  61. },
  62. // 文字大小
  63. fontSize: {
  64. type: [String, Number],
  65. default: 30
  66. },
  67. // 宽度
  68. itemWidth: {
  69. type: [String, Number],
  70. default: 'auto'
  71. }
  72. },
  73. methods: {
  74. change(index) {
  75. this.current = index;
  76. this.$emit('change', index);
  77. }
  78. }
  79. };
  80. </script>
  81. <style lang="scss" scoped>
  82. .slot {
  83. }
  84. </style>