[Vuejs]-VueJS how to update data on selection

2👍

You fiddle still contains some typo so it doesn’t work.

Please check: https://jsfiddle.net/u1n8x97e/39/

You don’t need to store the entire selected object. You can just keep the index.

<select v-model="selected">
  <option v-for="(foo, i) in foobar" :value="i">{{foo.name}}</option>
</select>

Now selected is just a number:

selected: 0

And you access the selected object by foobar[selected]

Leave a comment