0๐
โ
You can try this approach:
new Vue({
...
data: {
...
desiredItemCount: new Array(10)
},
...
});
And then use it in your template like this:
<div v-for="n in desiredItemCount" id="example">
<my-list-item></my-list-item>
</div>
0๐
the vue instance you attached to should have only one root node. Since you are using v-for
on the div with id example, 10 divs are created which have no root parent node.
So create a wrapper root node like this:
<script src="https://unpkg.com/vue"></script>
<div id=|example">
<div v-for="n in 10">
my-list-item></my-list-item>
</div>
</div>
Source:stackexchange.com