vue2-autocomplete
vue2-autocomplete copied to clipboard
How set Value on page load
initValue work if value is static
data(){ return { locality_name: 'aas' } }
when locality_name is changed by other function value is alwais "aas".
In documentation we have this.$refs.autocomplete.setValue(string) but not work. How can fix ?
@salvatorelapi you need to specify autocomplete as the ref for the child component, after which this.$refs.autocomplete.setValue(string)
will work:
<autocomplete
ref="autocomplete"
:url="userSearchUrl"
anchor="email"
label="first_name"
:on-select="addUser">
</autocomplete>
You can then set the value through:
export default {
props: ['userSearchUrl'],
components: {
autocomplete: Vue2Autocomplete
},
created: function() {
this.$refs.autocomplete.setValue('new value')
}
}
initValue not working import file data update autocomplete first item ?.
view
@NguyenTheSon i've got the same issue
@teddy-dubal you can use this.$refs.autocomplete.setValue solve the problem