index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <van-tabs :class="clazz" :active="tabActive" :ellipsis="false" @change="tabChange">
  3. <template v-for="(item, index) in tabs">
  4. <van-tab class="u-tab" :title="item.label" :name="item.value" :key="item.value"></van-tab>
  5. </template>
  6. </van-tabs>
  7. </template>
  8. <script>
  9. export default {
  10. options: {
  11. styleIsolation: 'shared'
  12. },
  13. props: {
  14. tabStyle: String,
  15. active: [String, Number],
  16. tabs: [Array]
  17. },
  18. computed: {
  19. clazz() {
  20. if (this.tabStyle === 'default') {
  21. return 'u-tabs u-tabs-detault'
  22. } else {
  23. return 'u-tabs'
  24. }
  25. }
  26. },
  27. watch: {
  28. active(val) {
  29. // this.tabActive = val
  30. }
  31. },
  32. data() {
  33. return {
  34. tabActive: undefined,
  35. data: [{
  36. label: '表面贴装',
  37. value: 1
  38. }, {
  39. label: '线束加工',
  40. value: 2
  41. }, {
  42. label: '工厂自动化',
  43. value: 3
  44. }, {
  45. label: '点胶注胶',
  46. value: 4
  47. }, {
  48. label: '电子制造服务',
  49. value: 5
  50. }, {
  51. label: '未来服务',
  52. value: 6
  53. }]
  54. }
  55. },
  56. created() {
  57. // this.tabActive = this.active
  58. },
  59. mounted() {
  60. },
  61. methods: {
  62. tabChange(e) {
  63. const detail = e.detail
  64. e.detail = {
  65. index: detail.index,
  66. label: detail.title,
  67. value: detail.name
  68. }
  69. this.tabActive = e.detail.name
  70. this.$emit('update:active', this.tabActive)
  71. this.$emit('change', e)
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. .u-tabs{
  78. --tabs-line-height: 64rpx;
  79. --tabs-card-height: 64rpx;
  80. --tabs-bottom-bar-height: rpx;
  81. --tab-active-text-color: #E57519;
  82. --tab-background-color: #F5F5F5;
  83. --tab-active-background-color: #F9E3D1;
  84. --tab-margin-right: 10rpx;
  85. --tab-border-radius: 20rpx;
  86. .van-tab{
  87. font-size: $fontSize2;
  88. line-height: 50rpx;
  89. }
  90. .van-tabs--line{
  91. height: 50rpx;
  92. }
  93. .van-tabs__scroll--line{
  94. height: 100%;
  95. }
  96. }
  97. .u-tabs.u-tabs-detault{
  98. --tabs-line-height: 48rpx;
  99. --tabs-card-height: 50rpx;
  100. --tabs-bottom-bar-height: 0;
  101. --tab-active-text-color: #FFFFFF;
  102. --tab-background-color: #FFFFFF;
  103. --tab-active-background-color: #E57519;
  104. --tab-margin-right: 13rpx;
  105. --tab-border-radius: 6rpx;
  106. .van-tabs__nav{
  107. padding: 0;
  108. }
  109. .van-tab{
  110. font-size: $fontSize1;
  111. border: 1rpx solid #7D7D7D;
  112. height: 50rpx;
  113. color: #7D7D7D;
  114. }
  115. .van-tab--active{
  116. border-color: #E57519!important;
  117. color: #FFFFFF;
  118. }
  119. .van-tabs__wrap--scrollable .van-tab--complete{
  120. flex: none!important;
  121. padding: 0 32rpx;
  122. }
  123. .van-tabs--line{
  124. height: 50rpx;
  125. }
  126. }
  127. .u-tab{
  128. margin-right: 20rpx;
  129. }
  130. </style>