Autocomplete
The v-autocomplete
component offers simple and flexible type-ahead functionality. This is useful when searching large sets of data or even dynamically requesting information from an API.
API
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
指定该组件应该分离到哪个DOM元素,使用CSS选择器字符串或元素的对象应用。
Components.Autocompletes.
启用自动聚焦
Components.Autocompletes.
应用备用输入框样式
Components.Autocompletes.
保留已经通过 items 属性的项在本地的唯一副本
改变一个已选择项为小纸片(chips)的显示方式
Components.Autocompletes.
添加输入框清除功能,默认图标是 Material Icons clear
将指定的色彩应用与控件
为输入长度创建一个计数器,如果未指定数字,则默认为25,不会应用任何验证。
应用暗黑主题变体
添加一个去除图标的到选定的小纸片(chips)
减小列表的最大高度
Components.Autocompletes.
键入时禁用自动字符显示
将输入框设置为手动错误状态。
Components.Autocompletes.
将输入框置于错误状态,并传入自定义的错误信息。将与来自规则(rules)属性的任何验证相结合。这个字段不会触发验证。
Components.Autocompletes.
Components.Autocompletes.
指定输入框为全屏宽度。
设置组件高度
Components.Autocompletes.
Components.Autocompletes.
不要在选择菜单中显示已选择的项
Components.Autocompletes.
设置 items 属性的头像
禁用 items 的属性值
设置items'属性的文本值
设置items属性的值
可以是一个对象数组或字符窜数组,当使用对象时,会查找文本和值字段,这可以使用 item-text 和 item-value 属性来改变。
Components.Autocompletes.
应用明亮主题变体
Components.Autocompletes.
将自定义字符掩码应用于输入框。有关更多信息,请参阅上面的掩码表格。
Components.Autocompletes.
Components.Autocompletes.
多选,接受数组作为值
当没有数据时显示的文本
Components.Autocompletes.
当使用 clearable 属性, 一旦清除,选择菜单将打开或保持打开,这个取决于当前状态
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
显示前缀
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
返回未修改的掩码字符串
将选择器的行为更改为直接返回对象,而不是 item-value 指定的值
Components.Autocompletes.
返回True或带有错误信息的字符串的函数数组。
使用自动补全(autocomplete)属性,使用 .sync 修饰符从自动补全搜索框中捕获用户的输入
Label does not move on focus/dirty
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
Components.Autocompletes.
显示后缀
设置输入类型
延迟验证直到失去焦点的事件被触发
控制可见性
Components.Autocompletes.
补充
Mask | Description |
---|---|
Masks | |
# | Any digit |
A | Any capital letter |
a | Any small letter |
N | Any capital alphanumeric character |
n | Any small alphanumeric character |
X | Any special symbol (-!$%^&*()_+|~=`{}[]:";'<>?,./\) or space |
Pre-made | |
credit-card | #### - #### - #### - #### |
date-with-time | ##/##/#### ##:## |
phone | (###) ### - #### |
social | ###-##-#### |
time | ##:## |
time-with-seconds | ##:##:## |
示例
Searching an API
Easily hook up dynamic data and create a unique experience. The v-autocomplete
's expansive prop list makes it easy to fine tune every aspect of the input.
Scoped slots
With the power of scoped slots, you can customize the visual output of the select. In this example we add a profile picture for both the chips and list items.
Custom filter on autocomplete
The filter
prop can be used to filter each individual item with custom logic. In this example we filter items by name
Asynchronous items
Sometimes you need to load data externally based upon a search query. Use the search-input
prop with the .sync modifier when using the autocomplete
prop. We also make use of the new cache-items
prop. This will keep a unique list of all items that have been passed to the items
prop and is REQUIRED when using asynchronous items and the multiple prop.
Advanced slots
The v-autocomplete
component is extremely flexible and can fit in just about any use-case. Create custom displays for no-data, item and selection slots to provide a unique user experience. Using scoped slots enables you to easily customize the desired look for your application.