index.wxml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. clear-trigger="{{ clearTrigger }}"
  23. clear-icon="{{ clearIcon }}"
  24. maxlength="{{ maxlength }}"
  25. input-align="{{ inputAlign }}"
  26. input-class="input-class"
  27. placeholder="{{ placeholder }}"
  28. placeholder-style="{{ placeholderStyle }}"
  29. cursor-spacing="{{ cursorSpacing }}"
  30. custom-style="padding: 5px 10px 5px 0; background-color: transparent;"
  31. bind:blur="onBlur"
  32. bind:focus="onFocus"
  33. bind:change="onChange"
  34. bind:confirm="onSearch"
  35. bind:clear="onClear"
  36. bind:click-input="onClickInput"
  37. >
  38. <slot wx:if="{{ useLeftIconSlot }}" name="left-icon" slot="left-icon" />
  39. <slot wx:if="{{ useRightIconSlot }}" name="right-icon" slot="right-icon" />
  40. </van-field>
  41. </view>
  42. <view
  43. wx:if="{{ showAction || useActionSlot }}"
  44. class="van-search__action"
  45. hover-class="van-search__action--hover"
  46. hover-stay-time="70"
  47. >
  48. <slot wx:if="{{ useActionSlot }}" name="action" />
  49. <view wx:else bind:tap="onCancel" class="van-search__action-button cancel-class">{{ actionText }}</view>
  50. </view>
  51. </view>