Skip to main content
InterviewHubPRO
Section Overview
Q41

Question 41 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

82%
Vue.js & Composition API (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Vue 3 Slots Deep Dive: Default, Named, Scoped Slots, and Dynamic Slot Names.

senior LevelCode ExampleSystem DesignVue & Nuxt

In Simple Words:

  • Default Slot: Injects content without a name (<slot />).
  • Named Slots: Target specific outlets (<slot name="header" />) using <template #header>.
  • Scoped Slots: Pass data from child up to parent template (<slot :item="item" />), allowing parents to customize render logic while children control data loops.
vue
<!-- Child: VirtualList.vue with Scoped Slot -->
<template>
  <ul>
    <li v-for="item in items" :key="item.id">
      <slot name="row" :item="item" :index="item.id">
        <!-- Default fallback content -->
        {{ item.name }}
      </slot>
    </li>
  </ul>
</template>

<!-- Parent Component Usage -->
<VirtualList :items="products">
  <template #row="{ item, index }">
    <span class="font-bold">#{{ index }}</span>: {{ item.name }} (${{ item.price }})
  </template>
</VirtualList>