index.wxml 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <view class="custom-class {{ utils.bem('tabs', [type]) }}">
  3. <view style="z-index: {{ zIndex }}; {{ wrapStyle }}" class="{{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}">
  4. <slot name="nav-left" />
  5. <scroll-view
  6. scroll-x="{{ scrollable }}"
  7. scroll-with-animation
  8. scroll-left="{{ scrollLeft }}"
  9. class="van-tabs__scroll--{{ type }}"
  10. style="{{ color ? 'border-color: ' + color : '' }}"
  11. >
  12. <view class="{{ utils.bem('tabs__nav', [type]) }} nav-class">
  13. <view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ lineStyle }}" />
  14. <view
  15. wx:for="{{ tabs }}"
  16. wx:key="index"
  17. data-index="{{ index }}"
  18. class="van-ellipsis tab-class {{ index === active ? 'tab-active-class' : '' }} {{ utils.bem('tab', { active: index === active, disabled: item.disabled }) }}"
  19. style="{{ color && index !== active && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === active && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}"
  20. bind:tap="onTap"
  21. >
  22. <view class="van-ellipsis {{ utils.bem('tab__title', { dot: item.dot }) }}" style="{{ item.titleStyle }}">
  23. {{ item.title }}
  24. <van-info
  25. wx:if="{{ item.info !== null }}"
  26. info="{{ item.info }}"
  27. custom-class="van-tab__title__info"
  28. />
  29. </view>
  30. </view>
  31. </view>
  32. </scroll-view>
  33. <slot name="nav-right" />
  34. </view>
  35. <view
  36. class="van-tabs__content"
  37. bind:touchstart="onTouchStart"
  38. bind:touchmove="onTouchMove"
  39. bind:touchend="onTouchEnd"
  40. bind:touchcancel="onTouchEnd"
  41. >
  42. <view class="van-tabs__track" style="{{ trackStyle }}">
  43. <slot />
  44. </view>
  45. </view>
  46. </view>