index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="tabs">
  3. <view class="one" :style="{background:tabs.bgColor||'#f9f9f9'}">
  4. <scroll-view class="scrollView" scroll-x="true">
  5. <view class="list" v-for="(item,index) in tabs.menu" :key="index"
  6. :style="{background:tabs.active==item.active?tabs.acbgColor||'#ffffff':''}"
  7. @tap="tabsChange(index,item)">
  8. <text :class="[tabs.active==item.active?'active_1':'active_2']">{{item.title}}</text>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. <slot></slot>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. tabs: {
  19. type: Object,
  20. },
  21. },
  22. data() {
  23. return {};
  24. },
  25. methods: {
  26. tabsChange(index, item) {
  27. const that = this;
  28. that.$emit('tabsChange', item)
  29. }
  30. }
  31. }
  32. </script>
  33. <style lang="scss">
  34. .tabs {
  35. .one {
  36. padding: 2vw;
  37. .scrollView {
  38. display: flex;
  39. white-space: nowrap;
  40. text-align: center;
  41. }
  42. .list {
  43. display: inline-block;
  44. padding: 2vw;
  45. margin: 0 1.5vw;
  46. text-align: center;
  47. border-radius: 5px;
  48. .active_1 {
  49. color: #000000;
  50. border-bottom: 4px solid #87CEFA;
  51. border-radius: 5px;
  52. }
  53. .active_2 {
  54. color: #999999;
  55. }
  56. text {
  57. font-weight: bold;
  58. font-size: 14px;
  59. }
  60. }
  61. }
  62. }
  63. </style>