Start range in v-for="n in 10" from zero

Viewed 18488

I want to start the range from 0 instead of 1 in v-for="n in 10" which results in 1 2 3 .... 10 Is there a way to do it in Vuejs?

3 Answers

You can also just subtract a value from your integer

<div v-for="n in 10">
  {{ n - 1 }}
</div>

This way you can have numbers with a negative value

Just use v-for="i in 10" and you got values 1...10. Also you should use use the key prop like below.

<div v-for="i in 10" :key="i">{{ i }}</div>

Output

1
2
3
...
Related