index.wxml 1004 B

12345678910111213141516171819202122232425262728293031
  1. <view
  2. class="van-picker-column custom-class"
  3. style="height: {{ itemHeight * visibleItemCount }}px"
  4. bind:touchstart="onTouchStart"
  5. catch:touchmove="onTouchMove"
  6. bind:touchend="onTouchEnd"
  7. bind:touchcancel="onTouchEnd"
  8. >
  9. <view style="{{ wrapperStyle }}">
  10. <view
  11. wx:for="{{ options }}"
  12. wx:for-item="option"
  13. wx:key="index"
  14. data-index="{{ index }}"
  15. style="height: {{ itemHeight }}px"
  16. class="van-ellipsis van-picker-column__item {{ option && option.disabled ? 'van-picker-column__item--disabled' : '' }} {{ index === currentIndex ? 'van-picker-column__item--selected active-class' : '' }}"
  17. bindtap="onClickItem"
  18. >{{ getOptionText(option, valueKey) }}</view>
  19. </view>
  20. </view>
  21. <wxs module="getOptionText">
  22. function isObj(x) {
  23. var type = typeof x;
  24. return x !== null && (type === 'object' || type === 'function');
  25. }
  26. module.exports = function (option, valueKey) {
  27. return isObj(option) && option[valueKey] ? option[valueKey] : option;
  28. }
  29. </wxs>