[Vuejs]-How to populate select options from json Array with VueJs

0👍

Try like following snippet:

new Vue({
  el: '#demo',
  data() {
    return {
      items: [{"select":["option1","option2","option3","option4"]}],
      selected: ''
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <select v-model="selected">
    <option disabled >Please select option</option>
    <option v-for="(item, i) in items[0].select" :key="i" :value="item">
      {{ item }}
    </option>
  </select>
  <h3>{{ selected }}</h3>
</div>

Leave a comment