vue.js - Vuetify 自动完成不显示包含多个搜索词的建议
问题描述
当我使用 Vuetify<v-autocomplete>
和我的 API 进行搜索时,mytext
只有myvalue
在写一个类似的词时才会正确更新和显示在建议中FOO
,如果我写一个类似的字符串,那么我在 API 调用方法中FOO BAR
得到正确的结果,但我得到了console.log(response.data)
的建议中没有任何内容<v-autocomplete>
。
<template>
:
<v-autocomplete
v-model="select"
:loading="loading"
:items="items"
item-text="mytext"
item-value="myvalue"
:search-input.sync="search"
hide-no-data
hide-details
label="My Autocomplete"
>
<template v-slot:item="data">
<v-list-item-content>
<v-list-item-title v-html="data.item.mytext"></v-list-item-title>
<v-list-item-subtitle
v-html="data.item.myvalue"
></v-list-item-subtitle
></v-list-item-content>
</template>
</v-autocomplete>
<script>
:
<script>
export default {
data() {
return {
select: null,
loading: false,
items: [],
search: null
}
},
watch: {
search(val) {
console.log('search: ' + val)
val && val !== this.select && this.query(val)
}
},
methods: {
async query(v) {
this.loading = true
await this.$axios
.get('/api/foo', {
params: {
search: this.search
}
})
.then((response) => {
console.log(response.data)
this.items = response.data
})
.catch((error) => {
console.log(error)
})
.finally(() => {
this.loading = false
})
}
}
}
</script>
该search
变量似乎与该items
变量相关联。
解决方案
我终于通过将此道具添加到以下内容来修复它<v-autocomplete>
:
:filter="() => true"
推荐阅读
- flutter - 即使在使用 Expanded 后出现“RenderBox 未布局”错误
- html - 模态窗口的 CSS 宽度和高度
- python - 为什么我不能用 python 中的字典值做数学运算?
- sql - SQL Server 中的主键重复
- java - 为什么 Math.Pow(x,y) 使用 double 而不是 long?
- php - 无法将 Visual Studio 代码连接到 PHP
- c++ - Windows:隐式链接位于不同文件夹中的 DLL
- angular - 从异步函数更新 Angular 视图
- tensorflow - TensorflowJS:如何在 TFJS 中重置预训练模型的输入/输出形状
- python - 更新 tkinter 接口上的当前值