[Vuejs]-Vue.js cycle does not work

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>

Fiddle: https://jsfiddle.net/50wL7mdz/69934/

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>

Leave a comment