[Vuejs]-Looping out slots?

0👍

As Michael said, you can achieve this behavior via scoped slots.

In your carousel component, the template will look like this :

<ul>
  // TODO : Add a :key with a unique identifier
  <li v-for="item in items">
    <slot name="item" :item="item">
      {{ item }}
    </template>
  </li>
</ul>

And when using the component, you will do something like this :

<carousel :items="images">
  <img #item="{ src }" :src="src">
</carousel>

Depending on your images data, you may need to get the source from another property.

Leave a comment