index.wxml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <wxs src="./index.wxs" module="computed" />
  3. <van-cell
  4. size="{{ size }}"
  5. icon="{{ leftIcon }}"
  6. title="{{ label }}"
  7. center="{{ center }}"
  8. border="{{ border }}"
  9. is-link="{{ isLink }}"
  10. required="{{ required }}"
  11. clickable="{{ clickable }}"
  12. title-width="{{ titleWidth }}"
  13. custom-style="{{ customStyle }}"
  14. arrow-direction="{{ arrowDirection }}"
  15. custom-class="van-field"
  16. >
  17. <slot name="left-icon" slot="icon" />
  18. <slot name="label" slot="title" />
  19. <view class="{{ utils.bem('field__body', [type]) }}">
  20. <textarea
  21. wx:if="{{ type === 'textarea' }}"
  22. class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}"
  23. fixed="{{ fixed }}"
  24. focus="{{ focus }}"
  25. cursor="{{ cursor }}"
  26. value="{{ innerValue }}"
  27. auto-focus="{{ autoFocus }}"
  28. disabled="{{ disabled || readonly }}"
  29. maxlength="{{ maxlength }}"
  30. placeholder="{{ placeholder }}"
  31. placeholder-style="{{ placeholderStyle }}"
  32. placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
  33. auto-height="{{ !!autosize }}"
  34. style="{{ computed.inputStyle(autosize) }}"
  35. cursor-spacing="{{ cursorSpacing }}"
  36. adjust-position="{{ adjustPosition }}"
  37. show-confirm-bar="{{ showConfirmBar }}"
  38. hold-keyboard="{{ holdKeyboard }}"
  39. selection-end="{{ selectionEnd }}"
  40. selection-start="{{ selectionStart }}"
  41. disable-default-padding="{{ disableDefaultPadding }}"
  42. bindinput="onInput"
  43. bindblur="onBlur"
  44. bindfocus="onFocus"
  45. bindconfirm="onConfirm"
  46. bindlinechange="onLineChange"
  47. bindkeyboardheightchange="onKeyboardHeightChange"
  48. >
  49. </textarea>
  50. <input
  51. wx:else
  52. class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}"
  53. type="{{ type }}"
  54. focus="{{ focus }}"
  55. cursor="{{ cursor }}"
  56. value="{{ innerValue }}"
  57. auto-focus="{{ autoFocus }}"
  58. disabled="{{ disabled || readonly }}"
  59. maxlength="{{ maxlength }}"
  60. placeholder="{{ placeholder }}"
  61. placeholder-style="{{ placeholderStyle }}"
  62. placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
  63. confirm-type="{{ confirmType }}"
  64. confirm-hold="{{ confirmHold }}"
  65. hold-keyboard="{{ holdKeyboard }}"
  66. cursor-spacing="{{ cursorSpacing }}"
  67. adjust-position="{{ adjustPosition }}"
  68. selection-end="{{ selectionEnd }}"
  69. selection-start="{{ selectionStart }}"
  70. password="{{ password || type === 'password' }}"
  71. bindinput="onInput"
  72. bindblur="onBlur"
  73. bindfocus="onFocus"
  74. bindconfirm="onConfirm"
  75. bindkeyboardheightchange="onKeyboardHeightChange"
  76. />
  77. <van-icon
  78. wx:if="{{ showClear }}"
  79. name="clear"
  80. class="van-field__clear-root van-field__icon-root"
  81. catch:touchstart="onClear"
  82. />
  83. <view class="van-field__icon-container" bind:tap="onClickIcon">
  84. <van-icon
  85. wx:if="{{ rightIcon || icon }}"
  86. name="{{ rightIcon || icon }}"
  87. class="van-field__icon-root {{ iconClass }}"
  88. custom-class="right-icon-class"
  89. />
  90. <slot name="right-icon" />
  91. <slot name="icon" />
  92. </view>
  93. <view class="van-field__button">
  94. <slot name="button" />
  95. </view>
  96. </view>
  97. <view wx:if="{{ showWordLimit && maxlength }}" class="van-field__word-limit">
  98. <view class="{{ utils.bem('field__word-num', { full: value.length >= maxlength }) }}">{{ value.length }}</view>/{{ maxlength }}
  99. </view>
  100. <view wx:if="{{ errorMessage }}" class="{{ utils.bem('field__error-message', [errorMessageAlign, { disabled, error }]) }}">
  101. {{ errorMessage }}
  102. </view>
  103. </van-cell>