-
zhangwei
2025-03-05 16213c0f85aa3ac8317797bf4a05fd12940e16d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import { AllowedComponentProps, VNodeProps } from './_common'
 
declare interface InputProps {
  /**
   * 输入的值
   */
  value?: string | number
  /**
   * 输入框类型,详见[文档](https://www.uviewui.com/components/input.html#%E8%BE%93%E5%85%A5%E6%A1%86%E7%9A%84%E7%B1%BB%E5%9E%8B)
   * @default "text"
   */
  type?: 'text' | 'number' | 'idcard' | 'digit' | 'password' | 'nickname'
  /**
   * 是否禁用输入框
   * @default false
   */
  disabled?: boolean
  /**
   * 禁用状态时的背景色
   * @default "#f5f7fa"
   */
  disabledColor?: string
  /**
   * 是否显示清除控件
   * @default false
   */
  clearable?: boolean
  /**
   * 是否密码类型
   * @default false
   */
  password?: boolean
  /**
   * 最大输入长度,设置为 -1 的时候不限制最大长度
   * @default -1
   */
  maxlength?: string | number
  /**
   * 输入框为空时的占位符
   */
  placeholder?: string
  /**
   * 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
   * @default "input-placeholder"
   */
  placeholderClass?: string
  /**
   * 指定placeholder的样式
   * @default "color: #c0c4cc"
   */
  placeholderStyle?: unknown
  /**
   * 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效
   * @default false
   */
  showWordLimit?: boolean
  /**
   * 设置右下角按钮的文字
   * @default "done"
   */
  confirmType?: 'send' | 'search' | 'next' | 'go' | 'done'
  /**
   * 点击键盘右下角按钮时是否保持键盘不收起,H5无效
   * @default false
   */
  confirmHold?: boolean
  /**
   * focus时,点击页面的时候不收起键盘,微信小程序有效
   * @default false
   */
  holdKeyboard?: boolean
  /**
   * 自动获取焦点,在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点
   * @default false
   */
  focus?: boolean
  /**
   * 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效
   * @default false
   */
  autoBlur?: boolean
  /**
   * 是否忽略组件内对文本合成系统事件的处理。为 false 时将触发 compositionstart、compositionend、compositionupdate 事件,且在文本合成期间会触发 input 事件
   * @default true
   */
  ignoreCompositionEvent?: boolean
  /**
   * 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效
   * @default false
   */
  disableDefaultPadding?: boolean
  /**
   * 指定focus时光标的位置
   * @default -1
   */
  cursor?: string | number
  /**
   * 输入框聚焦时底部与键盘的距离
   * @default 30
   */
  cursorSpacing?: string | number
  /**
   * 光标起始位置,自动聚集时有效,需与selection-end搭配使用
   * @default -1
   */
  selectionStart?: string | number
  /**
   * 光标结束位置,自动聚集时有效,需与selection-start搭配使用
   * @default -1
   */
  selectionEnd?: string | number
  /**
   * 键盘弹起时,是否自动上推页面
   * @default true
   */
  adjustPosition?: boolean
  /**
   * 输入框内容对齐方式
   * @default "left"
   */
  inputAlign?: 'left' | 'center' | 'right'
  /**
   * 输入框字体的大小
   * @default "15px"
   */
  fontSize?: string | number
  /**
   * 输入框字体颜色
   * @default "#303133"
   */
  color?: string
  /**
   * 输入框前置图标
   */
  prefixIcon?: string
  /**
   * 前置图标样式
   */
  prefixIconStyle?: unknown
  /**
   * 输入框后置图标
   */
  suffixIcon?: string
  /**
   * 后置图标样式
   */
  suffixIconStyle?: unknown
  /**
   * 边框类型,surround-四周边框,bottom-底部边框,none-无边框
   * @default "surround"
   */
  border?: 'surround' | 'bottom' | 'none'
  /**
   * 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会
   * @default false
   */
  readonly?: boolean
  /**
   * 输入框形状,circle-圆形,square-方形
   * @default "square"
   */
  shape?: 'square' | 'circle'
  /**
   * 输入过滤或格式化函数(如需兼容微信小程序,则只能通过`setFormatter`方法)
   */
  formatter?: (...args: any) => any
  /**
   * 定义需要用到的外部样式
   */
  customStyle?: unknown
  /**
   * 输入框失去焦点时触发
   * @param value 内容值
   */
  onBlur?: (value: any) => any
  /**
   * 输入框聚焦时触发
   */
  onFocus?: () => any
  /**
   * 点击完成按钮时触发
   * @param value 内容值
   */
  onConfirm?: (value: any) => any
  /**
   * 键盘高度发生变化的时候触发此事件
   */
  onKeyboardheightchange?: () => any
  /**
   * 内容发生变化触发此事件
   * @param value 内容值
   */
  onInput?: (value: any) => any
  /**
   * 内容发生变化触发此事件
   * @param value 内容值
   */
  onChange?: (value: any) => any
  /**
   * 点击清空内容
   */
  onClear?: () => any
}
 
declare interface InputSlots {
  /**
   * 输入框前置内容,`nuve`环境需`u--input`有效,非`nvue`环境需`u-input`才有效
   */
  ['prefix']?: () => any
  /**
   * 输入框后置内容,`nuve`环境需`u--input`有效,非`nvue`环境需`u-input`才有效
   */
  ['suffix']?: () => any
}
 
declare interface _Input {
  new (): {
    $props: AllowedComponentProps &
      VNodeProps &
      InputProps
    $slots: InputSlots
  }
}
 
declare interface _InputRef {
  /**
   * 为兼容微信小程序而暴露的内部方法
   */
  setFormatter: () => void
}
 
export declare const Input: _Input
 
export declare const InputRef: _InputRef