Skip to content
Advertisement

Component vue-multiselect- doesn’t fetch value on load

When loading a component, I need to select the value in the drop-down list

I’m trying to make my code friends with vue-multiselect

found a similar topic – however, nothing appears in the field – if you then select a value, everything works correctly link

in fact, I have to download via axios, the mini version looks like this

JavaScript

but when the form is loaded and opened – there is nothing in the select box,

and if you make a choice from the list, then the model changes

Screenshot

example

what am I doing wrong?

Advertisement

Answer

You forget just one line of code: in your multiselect tag add v-model="selectedBook", like

JavaScript

And if you want a book to be already selected when you load the component (so a default book, for example the first one). You have to modify your getFav() function, which is called when creating the component:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement