index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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" :style="{background:tabs.active==item.active?tabs.acbgColor||'#ffffff':''}" @tap="tabsChange(index,item)">
  6. <text :style="{color:tabs.active==item.active?tabs.actxtColor||'#000000':tabs.txtColor||'#999999'}">{{item.title}}</text>
  7. </view>
  8. </scroll-view>
  9. </view>
  10. <slot></slot>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. tabs: {
  17. type: Object,
  18. },
  19. },
  20. data() {
  21. return {};
  22. },
  23. methods: {
  24. tabsChange(index, item) {
  25. const that = this;
  26. that.$emit('tabsChange', item)
  27. }
  28. }
  29. }
  30. </script>
  31. <style lang="scss">
  32. .tabs {
  33. .one {
  34. padding: 2vw;
  35. .scrollView {
  36. display: flex;
  37. white-space: nowrap;
  38. text-align: center;
  39. }
  40. .list {
  41. display: inline-block;
  42. padding: 2vw;
  43. margin: 0 1.5vw;
  44. text-align: center;
  45. border-radius: 5px;
  46. text {
  47. font-weight: bold;
  48. font-size: 14px;
  49. }
  50. }
  51. }
  52. }
  53. </style>