Input 输入框
带浮动 Label 与错误抖动反馈的输入框,适用于绝大多数文本输入场景。
基础用法
vue
<AInput v-model="value" label="用户名" placeholder="请输入用户名" />错误态
错误时输入框会触发水平抖动动画(spring 缓动),并显示错误文案。
vue
<AInput
v-model="value"
label="邮箱"
:error="hasError"
error-message="邮箱格式不正确"
/>禁用
vue
<AInput model-value="已锁定" disabled />API
Props
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
modelValue | string | '' | 双向绑定值 |
type | 'text' | 'password' | 'email' | 'number' | 'search' | 'text' | 原生 type |
placeholder | string | — | 占位符 |
label | string | — | 浮动 Label 文案 |
disabled | boolean | false | 禁用 |
readonly | boolean | false | 只读 |
error | boolean | false | 错误态 |
errorMessage | string | — | 错误提示文案 |
Emits
| 名称 | 参数 | 说明 |
|---|---|---|
update:modelValue | string | 值更新 |
focus | FocusEvent | 聚焦 |
blur | FocusEvent | 失焦 |
暴露方法
| 名称 | 说明 |
|---|---|
focus() | 让输入框获取焦点 |