[Vuejs]-Vue get children of a component passed in a parent component

1๐Ÿ‘

โœ…

If I understand your question correctly, you want to use Slots.

In item-component you need to put in:

<slot></slot>

exactly where you want the value of i to be.

-1๐Ÿ‘

If you want to use i in scripts, just add property in item-component, for example named no and put it in for:

<div class="layout">
    <item-component v-for="i in 10" :key="i" :no="i" ></item-component>
</div>

Leave a comment