[Vuejs]-How can I get the index of an element and return it from my template in Vue Js?

1👍

Add a value attribute:

<select class="form-control" id="sel2" v-model="genre_id">
  <option v-for="genre in genres" v-bind:key="genre.id" :value="genre.id">
    {{ genre.name }}
  </option>
</select>

The value attribute specifies the value to be sent to a server when a form is submitted.

The content between the opening and closing tags is what the browsers will display in a drop-down list. However, the value of the value attribute is what will be sent to the server when a form is submitted.

Note: If the value attribute is not specified, the content will be passed as a value instead.

Reference

Leave a comment