9951 explained code solutions for 126 technologies


vue.jsHow do I use Vue.js to create a select option?


To create a select option using Vue.js, you can use the <select> tag and v-model directive. The v-model directive binds the select option to the value of the data property.

Example code

<select v-model="selectedOption">
  <option v-for="option in options" :value="option.value">
    {{ option.text }}
  </option>
</select>

In this example code, the v-model directive binds the select option to the value of the data property selectedOption. The v-for directive is used to loop through the options array and create <option> elements with the text and value of each item.

Code explanation

  • <select> tag - used to create the select option
  • v-model directive - binds the select option to the value of the data property
  • v-for directive - used to loop through the options array and create <option> elements with the text and value of each item

Helpful links

Edit this code on GitHub