[Vuejs]-How to use v-for with a Range and add additional input using push()

1👍

new Vue({
  el: "#app",
  data: {
    count: 5,
    form:{
    overAllScores:['','','','','']
    }
  },
  methods: {
  	add(){
    	let len = this.form.overAllScores.length
    	this.$set(this.form.overAllScores, len, '')
      this.count++
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <ol>
    <li v-for="(item,n) in count">
      <input v-model="form.overAllScores[n]">
    </li>
  </ol>
  <button @click="add">add</button>
  <div>
  {{JSON.stringify(form.overAllScores)}}
  </div>
</div>
👤sugars

Leave a comment