Make v-for only with number

1

Is it possible to make a v-for using only a total number?

Example:

I would pass a variable with value 10 , it would loop from 1 to 10, type the example in JS below:

for(var i = 1; i <= num_parcelas; i++){
      mostrar += "<option value='" + i + "'>" + i + "</option>";
    }
    
asked by anonymous 06.10.2018 / 16:34

1 answer

2

You use v-for with a range.

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script><divid="range" class="demo">
  <select>
    <option v-for="n in 10" :value="n">{{ n }}</option>
  </select>
</div>
<script>
  new Vue({ el: '#range' })
</script>

See documentation .

    
06.10.2018 / 16:44