0

I'm using the v-select from vuetify and it refreshes the data only after I leave the textfield and getback. It shows no data available even if we receive data from the server.

Code:

              <v-select
                :loading="loading"
                cache-items
                :search-input.sync="search"
                :debounce-search="0"
                v-model="select"
                label="Select"
                :items="items"
                autocomplete
                autofocus
              ></v-select>

Data:

data: () => ({
  state: null,
  states: [],
  loading: false,
  items: [],
  search: "",
  select: [],
}),
watch: {
  search(val) {
    val && this.querySelections(val)
  }
},
querySelections(v) {
  this.loading = true
  // Simulated ajax query


  var baseurl = "https://maps.googleapis.com/maps/api/geocode";
  var api = axios.create({
    baseURL: baseurl,
  });

  api.get(`/json?key=KEY&address=${v}`).then(({data}) => {
    for (var i = 0; i < data.results.length; i++) {
      console.log(data.results[i].place_id);
      this.states.push(data.results[i].place_id)
    }
  })

  setTimeout(() => {
    this.items = this.states
    this.loading = false
  }, 500)
}
jason
  • 3,932
  • 11
  • 52
  • 123

0 Answers0