Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

vue select option v-for selected

new Vue({
  el: '#app',
  data: function() {
    return {
      selectedFlavor: 'lime',
      flavors: ['blueberry', 'lime', 'strawberry']
    }
  },
  methods: {
    change: function() {
      this.selectedFlavor = 'strawberry';
    }
  }
})


<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.min.js"></script>
<div id="app">
  <button @click="change()">Set Strawberry</button>
  <select v-model="selectedFlavor">
    <option v-for="flavor in flavors" :value="flavor">{{flavor}}</option>
  </select>
</div>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #vue #select #option #selected
ADD COMMENT
Topic
Name
9+5 =