index.wxml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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"
  21. style="{{ computed.navStyle(color, type) }}">
  22. <view wx:if="{{ type === 'line' }}" class="van-tabs__line"
  23. style="{{ computed.lineStyle({ color, lineOffsetLeft, lineHeight, skipTransition, duration, lineWidth, inited }) }}"/>
  24. <view
  25. wx:for="{{ tabs }}"
  26. wx:key="index"
  27. data-index="{{ index }}"
  28. class="{{ computed.tabClass(index === currentIndex, ellipsis) }} {{ utils.bem('tab', { active: index === currentIndex, disabled: item.disabled, complete: !ellipsis }) }}"
  29. style="{{ computed.tabStyle({ active: index === currentIndex, ellipsis, color, type, disabled: item.disabled, titleActiveColor, titleInactiveColor, swipeThreshold, scrollable }) }}"
  30. bind:tap="onTap"
  31. >
  32. <view class="{{ ellipsis ? 'van-ellipsis' : '' }}" style="{{ item.titleStyle }}">
  33. {{ item.title }}
  34. <van-info
  35. wx:if="{{ item.info !== null || item.dot }}"
  36. info="{{ item.info }}"
  37. dot="{{ item.dot }}"
  38. custom-class="van-tab__title__info"
  39. />
  40. </view>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. <slot name="nav-right"/>
  45. </view>
  46. </van-sticky>
  47. <view
  48. class="van-tabs__content"
  49. bind:touchstart="onTouchStart"
  50. bind:touchmove="onTouchMove"
  51. bind:touchend="onTouchEnd"
  52. bind:touchcancel="onTouchEnd"
  53. >
  54. <view
  55. class="{{ utils.bem('tabs__track', [{ animated }]) }} van-tabs__track"
  56. style="{{ computed.trackStyle({ duration, currentIndex, animated }) }}"
  57. >
  58. <slot/>
  59. </view>
  60. </view>
  61. </view>