Skip to content

Input 输入框

通过鼠标或键盘输入内容,支持多种类型和尺寸。

基础用法

使用 v-model 绑定数据,通过 type 属性切换输入框类型。

可清空与密码切换

通过 clearable 属性可一键清空内容,showPassword 属性可切换密码显隐。

尺寸与字数限制

通过 size 属性调整输入框尺寸,maxlengthshowWordLimit 显示字数统计。

0/10

禁用与只读

通过 disabledreadonly 属性控制输入交互。

Input API

Props

参数说明类型默认值
modelValue绑定值string | number
type输入框类型text | password | textarea | number | email | tel | urltext
size输入框尺寸large | medium | smallmedium
placeholder占位文本string
disabled是否禁用booleanfalse
readonly是否只读booleanfalse
clearable是否可清空booleanfalse
showPassword是否可切换密码显隐booleanfalse
maxlength最大输入长度number
showWordLimit是否显示字数统计booleanfalse
rows文本域行数(textarea 类型)number3
resize文本域缩放策略none | both | horizontal | verticalvertical
autocomplete原生 autocomplete 属性stringoff
name原生 name 属性string
id原生 id 属性string

Events

事件名说明回调参数
update:modelValue输入值更新时触发(value: string | number)
input输入时触发(value: string)
change值变更时触发(value: string)
focus获取焦点时触发(event: FocusEvent)
blur失去焦点时触发(event: FocusEvent)
clear点击清空按钮时触发()

Slots

插槽名说明
prepend输入框前置内容
append输入框后置内容
prefix输入框头部图标
suffix输入框尾部图标或内容

基于 MIT 许可发布