index.wxml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <view
  3. class="{{ utils.bem('search', { withaction: showAction || useActionSlot }) }} custom-class"
  4. style="background: {{ background }}"
  5. >
  6. <view class="{{ utils.bem('search__content', [shape]) }}">
  7. <view class="van-search__label" wx:if="{{ label }}">{{ label }}</view>
  8. <slot wx:else name="label" />
  9. <van-field
  10. type="search"
  11. left-icon="{{ !useLeftIconSlot ? leftIcon : '' }}"
  12. right-icon="{{ !useRightIconSlot ? rightIcon : '' }}"
  13. focus="{{ focus }}"
  14. error="{{ error }}"
  15. border="{{ false }}"
  16. confirm-type="search"
  17. class="van-search__field field-class"
  18. value="{{ value }}"
  19. disabled="{{ disabled }}"
  20. readonly="{{ readonly }}"
  21. clearable="{{ clearable }}"
  22. maxlength="{{ maxlength }}"
  23. input-align="{{ inputAlign }}"
  24. input-class="input-class"
  25. placeholder="{{ placeholder }}"
  26. placeholder-style="{{ placeholderStyle }}"
  27. custom-style="padding: 5px 10px 5px 0; background-color: transparent;"
  28. bind:blur="onBlur"
  29. bind:focus="onFocus"
  30. bind:change="onChange"
  31. bind:confirm="onSearch"
  32. bind:clear="onClear"
  33. >
  34. <slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" />
  35. <slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" />
  36. </van-field>
  37. </view>
  38. <view
  39. wx:if="{{ showAction || useActionSlot }}"
  40. class="van-search__action"
  41. hover-class="van-search__action--hover"
  42. hover-stay-time="70"
  43. >
  44. <slot wx:if="{{ useActionSlot }}" name="action" />
  45. <view wx:else bind:tap="onCancel" class="cancel-class">{{ actionText }}</view>
  46. </view>
  47. </view>