В моем случае у меня есть пользовательские сообщения с похожим заголовком из моего локального API, и я попытался показать сообщения по поисковому запросу из массива items.
Данные:
{
"count": 5,
"entries": [
{
"id": 3,
"title": "Senior developer Python"
},
{
"id": 4,
"title": "Senior developer Python"
},
{
"id": 5,
"title": "Senior developer Python"
}
]
}
Код автозаполнения Vuetify:
<v-autocomplete
v-model = "model"
:items = "items"
:loading = "isLoading"
:search-input.sync = "search"
color = "white"
hide-no-data
hide-selected
item-text = "Description"
item-value = "API"
return-object
></v-autocomplete>
Javascript-код:
<script>
export default {
data: () => ({
descriptionLimit: 60,
entries: [],
isLoading: false,
model: null,
search: null
}),
computed: {
items () {
return this.entries.map(entry => {
const Description = entry.title.length > this.descriptionLimit
? entry.title.slice(0, this.descriptionLimit) + '...'
: entry.title
return Object.assign({}, entry, { Description })
})
}
},
watch: {
search (val) {
// Items have already been requested
if (this.isLoading) return
this.isLoading = true
// Lazily load input items
fetch('https://api.website.org/posts')
.then(res => res.json())
.then(res => {
const { count, entries } = res
this.count = count
this.entries = entries
})
.catch(err => {
console.info(err)
})
.finally(() => (this.isLoading = false))
}
}
}
</script>
Как я могу показать в своем автозаполнении все похожие сообщения по названию?



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Обратите внимание, что автозаполнение также пытается найти точные совпадения в ваших элементах. Возможно, для предложений на стороне сервера вам следует использовать v-combobox.
Я не понимаю, как пользователь различает одинаковые тексты? вы просто хотите, чтобы они появились несколько раз?