index.wxml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template name="toolbar">
  2. <view
  3. wx:if="{{ showToolbar }}"
  4. class="van-picker__toolbar van-hairline--top-bottom toolbar-class"
  5. >
  6. <view
  7. class="van-picker__cancel"
  8. hover-class="van-picker__cancel--hover"
  9. hover-stay-time="70"
  10. data-type="cancel"
  11. bindtap="emit"
  12. >
  13. {{ cancelButtonText }}
  14. </view>
  15. <view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{ title }}</view>
  16. <view
  17. class="van-picker__confirm"
  18. hover-class="van-picker__confirm--hover"
  19. hover-stay-time="70"
  20. data-type="confirm"
  21. bindtap="emit"
  22. >
  23. {{ confirmButtonText }}
  24. </view>
  25. </view>
  26. </template>
  27. <view class="van-picker custom-class">
  28. <template is="toolbar" wx:if="{{ toolbarPosition === 'top' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
  29. <view wx:if="{{ loading }}" class="van-picker__loading">
  30. <loading color="#1989fa"/>
  31. </view>
  32. <view
  33. class="van-picker__columns"
  34. style="height: {{ itemHeight * visibleItemCount }}px"
  35. catch:touchmove="noop"
  36. >
  37. <picker-column
  38. class="van-picker__column"
  39. wx:for="{{ isSimple(columns) ? [columns] : columns }}"
  40. wx:key="index"
  41. data-index="{{ index }}"
  42. custom-class="column-class"
  43. value-key="{{ valueKey }}"
  44. initial-options="{{ isSimple(columns) ? item : item.values }}"
  45. default-index="{{ item.defaultIndex || defaultIndex }}"
  46. item-height="{{ itemHeight }}"
  47. visible-item-count="{{ visibleItemCount }}"
  48. active-class="active-class"
  49. bind:change="onChange"
  50. />
  51. <view
  52. class="van-picker__frame van-hairline--top-bottom"
  53. style="height: {{ itemHeight }}px"
  54. />
  55. </view>
  56. <template is="toolbar" wx:if="{{ toolbarPosition === 'bottom' }}" data="{{ showToolbar, cancelButtonText, title, confirmButtonText }}"></template>
  57. </view>
  58. <wxs module="isSimple">
  59. function isSimple(columns) {
  60. return columns.length && !columns[0].values;
  61. }
  62. module.exports = isSimple;
  63. </wxs>