index.wxml 3.8 KB

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