<template>
<v-suggest
v-model="search"
:data="this.suggestions"
></v-suggest>
</template>
<script>
import { Suggest } from 'v-suggest'
import axios from 'axios'
export default {
components: {
'v-suggest': CustomVSuggest
},
data() {
return {
search: '',
suggestions: [],
}
},
methods: {
getSuggestions: function() {
return axios.get('/api/search/' + this.search)
.then(response => {
this.suggestions = response.data
})
},
},
watch: {
search: function(newValue, oldValue) {
this.getSuggestions()
}
}
}
</script>
The workaround I'm using right now is creating a component that extends yours and just calls this.focus()
whenever data
changes. And then of course using this in place of the v-suggest component.
<script>
import { Suggest } from 'v-suggest'
export default {
extends: Suggest,
watch: {
data(newValue, oldValue) {
this.focus()
}
}
}
</script>
watch: {
data(newValue, oldValue) {
this.focus()
}
}