index.wxml 3.85 KB
Newer Older
李嘉林 committed
1
<wxs src="../wxs/utils.wxs" module="utils" />
程默 committed
2
<wxs src="./index.wxs" module="computed" />
李嘉林 committed
3 4 5 6 7 8 9 10 11 12

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