index.wxml 3.7 KB

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