index.wxml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <wxs src="./index.wxs" module="computed" />
  3. <view class="custom-class {{ utils.bem('tabs') }}">
  4. <van-sticky
  5. disabled="{{ !sticky }}"
  6. z-index="{{ zIndex }}"
  7. offset-top="{{ offsetTop }}"
  8. container="{{ container }}"
  9. bind:scroll="onTouchScroll"
  10. >
  11. <view class="{{ utils.bem('tabs--') + type }} {{ utils.bem('tabs__wrap', { scrollable }) }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }} wrap-class">
  12. <slot name="nav-left" />
  13. <scroll-view
  14. scroll-x="{{ scrollable }}"
  15. scroll-with-animation="{{ scrollWithAnimation }}"
  16. scroll-left="{{ scrollLeft }}"
  17. class="{{ utils.bem('tabs__scroll', [type]) }}"
  18. style="{{ color ? 'border-color: ' + color : '' }}"
  19. >
  20. <view class="{{ utils.bem('tabs__nav', [type, { complete: !ellipsis }]) }} nav-class" style="{{ computed.navStyle(color, type) }}">
  21. <view wx:if="{{ type === 'line' }}" class="van-tabs__line" style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth, inited }) }}" />
  22. <view
  23. wx:for="{{ tabs }}"
  24. wx:key="index"
  25. data-index="{{ index }}"
  26. class="{{ computed.tabClass(index === currentIndex, ellipsis) }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled, complete: !ellipsis }) }}"
  27. style="{{ computed.tabStyle({ active: index === currentIndex, ellipsis, color, type, disabled: item.disabled, titleActiveColor, titleInactiveColor, swipeThreshold, scrollable }) }}"
  28. bind:tap="onTap"
  29. >
  30. <view class="{{ ellipsis ? 'van-ellipsis' : '' }}" style="{{ item.titleStyle }}">
  31. {{ item.title }}
  32. <van-info
  33. wx:if="{{ item.info !== null || item.dot }}"
  34. info="{{ item.info }}"
  35. dot="{{ item.dot }}"
  36. custom-class="van-tab__title__info"
  37. />
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. <slot name="nav-right" />
  43. </view>
  44. </van-sticky>
  45. <view
  46. class="van-tabs__content"
  47. bind:touchstart="onTouchStart"
  48. bind:touchmove="onTouchMove"
  49. bind:touchend="onTouchEnd"
  50. bind:touchcancel="onTouchEnd"
  51. >
  52. <view
  53. class="{{ utils.bem('tabs__track', [{ animated }]) }} van-tabs__track"
  54. style="{{ computed.trackStyle({ duration, currentIndex, animated }) }}"
  55. >
  56. <slot />
  57. </view>
  58. </view>
  59. </view>