app-tab-nav.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <view
  4. :class="[shadow ? `main-between app-nav shadow` : 'main-between app-nav']"
  5. :style="[
  6. {
  7. 'line-height': `${setHeight ? setHeight : 90}rpx`,
  8. 'font-size': `${fontSize ? fontSize : 28}rpx`,
  9. 'height': `${setHeight ? setHeight : 90}rpx`,
  10. 'top': `${setTop ? setTop : 0}rpx`,
  11. 'backgroundColor': `${background ? background : '#fff'}`,
  12. }
  13. ]"
  14. >
  15. <view @click="handleClick" v-for="(item) in tabList" :key="item.id" :data-id="item.id" class="box-grow-1 nav-item"
  16. :style="[
  17. {
  18. 'borderBottom': `${border ? 1 : 0}rpx solid #e2e2e2`,
  19. }
  20. ]"
  21. >
  22. <text
  23. :class="[item.id == activeItem ? `active-text ${theme}-m-text ` + theme : '']"
  24. :style="[
  25. {
  26. 'height': `${setHeight ? setHeight : 90}rpx`,
  27. 'padding': `0 ${padding}rpx`,
  28. }
  29. ]"
  30. >{{item.name}}</text>
  31. </view>
  32. </view>
  33. <view
  34. :style="[
  35. {'height': `${placeHeight ? placeHeight : 90}rpx`}
  36. ]"
  37. >
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. name: 'app-tab-nav',
  44. props: {
  45. background: String,
  46. setTop: String,
  47. padding: {
  48. default: '45',
  49. type: String,
  50. },
  51. setHeight: String,
  52. placeHeight: String,
  53. fontSize: String,
  54. theme: {
  55. default: 'default',
  56. type: String,
  57. },
  58. border: {
  59. default: true,
  60. type: Boolean,
  61. },
  62. shadow: {
  63. default: true,
  64. type: Boolean,
  65. },
  66. activeItem: String,
  67. tabList: Array
  68. },
  69. methods: {
  70. handleClick(e) {
  71. this.$emit('click', e);
  72. }
  73. },
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .app-nav {
  78. color: #353535;
  79. width: 100%;
  80. position: fixed;
  81. left: 0;
  82. background-color: #fff;
  83. z-index: 11;
  84. .nav-item {
  85. text-align: center;
  86. text {
  87. display: inline-block;
  88. }
  89. }
  90. .active-text {
  91. border-bottom: #{4rpx} solid;
  92. }
  93. }
  94. .app-nav.shadow {
  95. box-shadow: 0 #{2rpx} #{10rpx} rgba(0, 0, 0, 0.06);
  96. }
  97. .default-m-text {
  98. color: #ff4544;
  99. }
  100. .blue-m-text {
  101. color: #446dfd;
  102. }
  103. </style>