1

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?

1

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.