v-navtab.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <view class="v-navtab">
  4. <u-tabs
  5. :list="list"
  6. :current="current"
  7. @change="changeTab"
  8. :name="name"
  9. :duration="duration"
  10. :active-color="activeColor"
  11. :is-scroll="isScroll"
  12. :inactive-color="inactiveColor"
  13. :bar-width="barWidth"
  14. :bar-height="barHeight"
  15. :bg-color="bgColor"
  16. :bold="bold"
  17. ></u-tabs>
  18. </view>
  19. <u-gap height="80"></u-gap>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. props: {
  25. list: {
  26. type: Array,
  27. default: () => []
  28. },
  29. name: {
  30. type: String,
  31. default: 'name'
  32. },
  33. isScroll: {
  34. type: Boolean,
  35. default: false
  36. },
  37. duration: {
  38. type: [Number, String],
  39. default: '0.2'
  40. },
  41. // 选中项的颜色
  42. activeColor: {
  43. type: String,
  44. default: '#E54A48'
  45. },
  46. // 未选中项的颜色
  47. inactiveColor: {
  48. type: String,
  49. default: '#303133'
  50. },
  51. // 菜单底部移动的bar的宽度,单位rpx
  52. barWidth: {
  53. type: [String, Number],
  54. default: 80
  55. },
  56. // 移动bar的高度
  57. barHeight: {
  58. type: [String, Number],
  59. default: 6
  60. },
  61. bgColor: {
  62. type: String,
  63. default: '#fff'
  64. },
  65. bold: {
  66. type: Boolean,
  67. default: true
  68. },
  69. },
  70. data() {
  71. return {
  72. current: 0
  73. }
  74. },
  75. methods: {
  76. changeTab(e) {
  77. this.current = e
  78. this.$emit('change', e)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .v-navtab {
  85. position: fixed;
  86. top: 0;
  87. width: 750rpx;
  88. border-bottom: 1rpx solid #eee;
  89. z-index: 999;
  90. }
  91. </style>