alexurquhart / vue-bootstrap-typeahead

An autocomplete/typeahead component for Vue 2 and Bootstrap 4
https://alexurquhart.github.io/vue-bootstrap-typeahead/
MIT License
206 stars 157 forks source link

v-model does not show the value of the attribute loaded in created() or mounted() #77

Open LucasS03 opened 4 years ago

LucasS03 commented 4 years ago

Value of attribute q not load if alter in created() or mounted(), as in my example:

HTML:

<vue-bootstrap-typeahead
   v-model="q"
   :data="list"
   :serializer="i => i.name"
   placeholder="Choose your bank"
   @hit="selectedItem($event)"
   class="vue-autocomplete">
</vue-bootstrap-typeahead>

JAVASCRIPT:

data() {
   return {
      q: "",
      list: []
   }
},
mounted() {
   this.q = loadValueDatabase();
}

The value of attribute q is altered, but not renderized in v-model

ttodua commented 4 years ago

I doubt similar issue has been opened, check there if any update.

mark-stephen-maduro commented 4 years ago

You can use ref to add loaded value.

<vue-bootstrap-typeahead ref="typeahead" v-model="q" :data="list" :serializer="i => i.name" placeholder="Choose your bank" @hit="selectedItem($event)" class="vue-autocomplete">

mounted() { this.$refs.typeahead.inputValue = loadValueDatabase(); }