Eddie Dane
Eddie Dane

Reputation: 1589

Why doesn’t VueJs natively support multiple select

am new to vue, while building an update form, I had an issue pre-selecting multiple option when multiple selected attribute is specified only the last one get selected and I also discovered the selected attribute is never rendered by vue!

I found a vue package that supports this vue-multiselect

But I just want to know why vue doesn’t support this and I have to use another library?

Upvotes: 0

Views: 685

Answers (1)

Michal Levý
Michal Levý

Reputation: 37853

Vue is a declarative Model-View rendering framework, not a component library. All Vue does is rendering HTML. In this sense "Vue can do" whatever HTML can do....

HTML <select> element allows to use multiple attribute and Vue supports it with it's v-model directive but you must bind to an array

Why v-model ignores selected attribute ?

Documentation

v-model will ignore the initial value, checked, or selected attributes found on any form elements. It will always treat the Vue instance data as the source of truth. You should declare the initial value on the JavaScript side, inside the data option of your component.

Upvotes: 1

Related Questions