index.wxml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <import src="./toolbar.wxml" />
  2. <view class="van-picker custom-class">
  3. <template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
  4. <view wx:if="{{ loading }}" class="van-picker__loading">
  5. <loading color="#1989fa"/>
  6. </view>
  7. <view
  8. class="van-picker__columns"
  9. style="height: {{ itemHeight * visibleItemCount }}px"
  10. catch:touchmove="noop"
  11. >
  12. <picker-column
  13. class="van-picker__column"
  14. wx:for="{{ isSimple(columns) ? [columns] : columns }}"
  15. wx:key="index"
  16. data-index="{{ index }}"
  17. custom-class="column-class"
  18. value-key="{{ valueKey }}"
  19. initial-options="{{ isSimple(columns) ? item : item.values }}"
  20. default-index="{{ item.defaultIndex || defaultIndex }}"
  21. item-height="{{ itemHeight }}"
  22. visible-item-count="{{ visibleItemCount }}"
  23. active-class="active-class"
  24. bind:change="onChange"
  25. />
  26. <view class="van-picker__mask" style="background-size: 100% {{ (itemHeight * visibleItemCount - itemHeight) / 2 }}px" />
  27. <view
  28. class="van-picker__frame van-hairline--top-bottom"
  29. style="height: {{ itemHeight }}px"
  30. />
  31. </view>
  32. <template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
  33. </view>
  34. <wxs module="isSimple">
  35. function isSimple(columns) {
  36. return columns.length && !columns[0].values;
  37. }
  38. module.exports = isSimple;
  39. </wxs>