Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to print a component as many times as an int. Something like:
x = 5; while(x >= 5) { <component></component> x++; }
I know about v-for loop but I would like to print with a number not with an array. Is it possible?
v-for
v-for="x in 5"
v-for can be also used in a range:
new Vue({ el:"#app" });
.as-console-wrapper { max-height: 40%!important; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="app"> <ul> <li v-for="index in 5" :key="index">{{index}}</li> </ul> </div>
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
v-forwith a range? vuejs.org/v2/guide/list.html#v-for-with-a-Rangev-for="x in 5"