index.wxml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <template name="zan-tab">
  2. <view class="zan-tab">
  3. <block wx:if="{{ tab.scroll || scroll }}">
  4. <scroll-view
  5. class="zan-tab__bd zan-tab__bd--scroll {{ fixed ? 'zan-tab__bd--fixed' : '' }}"
  6. scroll-x="true"
  7. style="height: {{ tab.height || height ? ((tab.height || height) + 'px') : 'auto' }}"
  8. >
  9. <template
  10. is="zan-tab-list"
  11. data="{{ list: tab.list || list, selectedId: tab.selectedId || selectedId, componentId }}">
  12. </template>
  13. </scroll-view>
  14. </block>
  15. <block wx:else>
  16. <view class="zan-tab__bd {{ fixed ? 'zan-tab__bd--fixed' : '' }}">
  17. <template
  18. is="zan-tab-list"
  19. data="{{ list: tab.list || list, selectedId: tab.selectedId || selectedId, componentId }}">
  20. </template>
  21. </view>
  22. </block>
  23. </view>
  24. </template>
  25. <template name="zan-tab-list">
  26. <view
  27. wx:for="{{ list }}"
  28. wx:key="id"
  29. class="zan-tab__item {{ selectedId == item.id ? 'zan-tab__item--selected' : '' }}"
  30. data-component-id="{{ componentId }}"
  31. data-item-id="{{ item.id }}"
  32. bindtap="_handleZanTabChange"
  33. >
  34. <view class="zan-tab__title">{{ item.title }}</view>
  35. </view>
  36. </template>