自动补全输入框

根据输入内容提供对应的输入建议

自定义模板

自定义如何显示输入建议。

远程搜索

从服务端搜索数据

Autocomplete 属性

参数属性详情类型可选值默认值
placeholder占位文本string
clearable是否可清空booleanfalse
disabled是否禁用booleanfalse
value-key输入建议对象中用于显示的键名stringvalue
icon图标组件string / Component
model-value / v-model选中项绑定值string
debounce获取输入建议的防抖延时number300
placement菜单弹出位置stringtop / top-start / top-end / bottom / bottom-start / bottom-endbottom-start
fetch-suggestions获取输入建议的方法, 仅当你的输入建议数据 resolve 时,通过调用 callback(data:[]) 来返回它Function(queryString, callback)
popper-class下拉列表的类名string
trigger-on-focus是否在输入框 focus 时显示建议列表booleantrue
name等价于原生 input name 属性string
select-when-unmatched在输入没有任何匹配建议的情况下,按下回车是否触发 select 事件booleanfalse
label标签文本string
prefix-icon输入框头部图标string / Component
suffix-icon输入框尾部图标string / Component
hide-loading是否隐藏远程加载时的加载图标booleanfalse
popper-append-to-body(deprecated)是否将下拉列表插入至 body 元素。 在下拉列表的定位出现问题时,可将该属性设置为 falsebooleanfalse
teleported是否将下拉列表插入至 body 元素booleantrue / falsetrue
highlight-first-item是否默认突出显示远程搜索建议中的第一项booleanfalse
fit-input-width下拉框是否与输入框同宽booleanfalse

Autocomplete 插槽

插槽名详情
自定义输入建议的内容。 自定义标签,参数为
prefix输入框占位文本
suffix输入框尾部内容
prepend输入框前置内容
append输入框后置内容

Autocomplete 事件

事件名描述说明参数
select点击选中建议项时触发选中的建议项
change在 Input 值改变时触发(value: string | number)

Autocomplete 方法

方法详情参数
focus使 input 获取焦点
blur使 input 失去焦点

源代码

组件文档

贡献者