如何清除自动完成的缓存项目列表?我正在使用cache-items标志。一旦用户获得了当前查询的结果并想尝试一个新列表,我就需要清除当前项目。
我启用了“缓存项”,因此用户可以在提交之前查看所有选择。
<v-autocomplete v-if="showautocomplete" v-model="autocomplete_model"
:items="items" :loading="isLoading" autofocus
:search-input.sync="autocomplete_search" chips clearable hide-selected cache-items>
答案 0 :(得分:0)
我不知道您是否还需要这个,但我想我在这里找到了答案:https://github.com/vuetifyjs/vuetify/issues/11365 来自 bka9。
您可以在 v-autocomplete 上添加一个 ref 并通过 $refs 更改缓存项。我不确定您什么时候必须触发该方法,但仅此而已。
<template>
<v-autocomplete ref="autocomplete" cache-items ... />
</template>
<script>
methods: {
clearCachedItems() {
this.$refs.autocomplete.cachedItems = [];
},
},
</script>