Is it possible to use Vue.js to render a component multiple times based on a variable?
For instance, I have a size variable set to 5 and I want to display the Widget component 5 times.
Here is my current code snippet:
Template :
<template>
<div v-for="item in size" :key="item">
<Widget/>
</div>
</template>
Script :
import Widget from './Widget'
export default {
data () {
return {
size: 5
}
},
components: {
Widget
}
}
I've tried using v-for
but I'm having trouble understanding its functionality.