Vuetify v0.17.6:如何在v-select中获取自动完成文本 [英] Vuetify v0.17.6: How to get the autocomplete text inside v-select
问题描述
我正在使用VueJS v2.5.13和Vuetify v0.17.6。
I'm using VueJS v2.5.13 and Vuetify v0.17.6.
我正在构建一个具有自动填充功能的选择,每当用户输入不在列表中的内容时,他们就能看到创建新选项的操作以下代码显示:
I'm building a select with autocomplete functionality and whenever the user types something that's not on the list they'll be able to see a action to create a new option as the code below shows:
<template>
<v-select prepend-icon="view_list" :items="options" label="Quick searches" v-model="selected" item-text="label" autocomplete :search-value="inputText" clearable dense>
<template slot="item" slot-scope="data">
<v-flex xs12>
<v-layout>
<v-layout justify-start fill-height align-content-center>
<span>{{data.item.label}}</span>
</v-layout>
<v-layout justify-end row>
<v-icon color="success" @click="edit(data)">mod_edit</v-icon>
<v-icon color="error" @click="del(data)">delete_forever</v-icon>
</v-layout>
</v-layout>
</v-flex>
</template>
<template slot="no-data">
<v-container>
<v-layout row>
<v-layout justify-start fill-height align-content-center>
Create new search
</v-layout>
<v-layout justify-end>
<v-icon color="success" @click="create()">add</v-icon>
</v-layout>
</v-layout>
</v-container>
</template>
</v-select>
我如何访问文本用户正在键入以使用用户自动填充文本作为标签创建新的快速搜索?
How can i access the text the user is typing to create a new 'quick search' using the user autocomplete text as label?
推荐答案
您可以通过以下方式绑定它使用:search-input.sync
:
You can bind it by using :search-input.sync
:
<v-select :search-input.sync="searchInput">
将 searchInput
变量添加到数据
data() {
return {
//...
searchInput: "",
};
},
此外,如果由于 debounce-似乎滞后搜索
属性,增加200毫秒延迟。如果你想在每次更改时捕获值,可以将其更改为0:
Additionally, if it seems "laggy" that's because of debounce-search
property, which adds 200ms delay. You can change it to 0 if you want to catch value every time it's changed:
:debounce-search="0"
这篇关于Vuetify v0.17.6:如何在v-select中获取自动完成文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!