Slots & Built-ins Questions with Answers

10 practice questions on Slots & Built-ins (Vue.js) with answers and step-by-step solutions. Try 10 samples below, then practise all 10 free in the AptiNest app.

Sample questions

Question 1Easy

Which built-in caches component instances when toggling between them?

  1. <Cache>
  2. <KeepAlive>
  3. <Suspense>
  4. <Hold>

Answer: B. <KeepAlive>

Explanation

KeepAlive preserves state of inactive components instead of destroying them.

Step-by-step solution

  1. Wrap dynamic component.
  2. State survives toggling.

Why the other options are wrong

  • A. <Cache> is not a built-in Vue component; the correct choice is <KeepAlive>.
  • C. Suspense handles async dependencies.
  • D. <Hold> is not a built-in Vue component; the correct choice is <KeepAlive>.

Question 2Easy

Which component helps animate an element when it enters or leaves via v-if?

  1. <Animate>
  2. <Motion>
  3. <Tween>
  4. <Transition>

Answer: D. <Transition>

Explanation

Transition applies CSS classes such as v-enter-from and v-leave-active.

Step-by-step solution

  1. Wrap one element.
  2. Define CSS classes.

Why the other options are wrong

  • A. <Animate> is not a built-in Vue component; the correct choice is <Transition>.
  • B. <Motion> is not a built-in Vue component; the correct choice is <Transition>.
  • C. <Tween> is not a built-in Vue component; the correct choice is <Transition>.

Question 3Easy

Which shorthand is used for v-slot:header?

  1. @header
  2. #header
  3. &header
  4. $header

Answer: B. #header

Explanation

# is the shorthand for v-slot:.

Step-by-step solution

  1. Use <template #header>.
  2. Content fills the named slot.

Why the other options are wrong

  • A. @ is v-on.
  • C. & is not a shorthand for v-slot; # is.
  • D. $ is not a shorthand for v-slot; # is.

Question 4Easy

Which component animates a list rendered with v-for?

  1. <TransitionGroup>
  2. <Transition> only
  3. <ListAnim>
  4. <KeepAlive>

Answer: A. <TransitionGroup>

Explanation

TransitionGroup animates additions, removals and moves of items, and needs unique keys.

Step-by-step solution

  1. Wrap the v-for.
  2. Give keys.

Why the other options are wrong

  • B. Transition handles a single element.
  • C. <ListAnim> is not a built-in Vue component; the correct choice is <TransitionGroup>.
  • D. KeepAlive caches.

Question 5Easy

What does <Teleport to="body"> do?

  1. Renders its content under a different DOM node while keeping it logically in the component
  2. Sends data to the server in the background while the component stays on the page
  3. Copies the component
  4. Hides it from the DOM

Answer: A. Renders its content under a different DOM node while keeping it logically in the component

Explanation

Teleport is useful for modals and tooltips that must escape overflow or z-index contexts.

Step-by-step solution

  1. Wrap content in Teleport.
  2. Set the target.

Why the other options are wrong

  • B. Not a network feature.
  • C. It moves, not copies.
  • D. It is displayed.

Question 6Medium

How do you define an async component with lazy loading?

  1. lazy(Big.vue), a helper that wraps the component file name for deferred loading
  2. asyncImport('./Big.vue')
  3. defineAsyncComponent(() => import('./Big.vue'))
  4. new Component('./Big.vue')

Answer: C. defineAsyncComponent(() => import('./Big.vue'))

Explanation

The loader returns a Promise; the code is split into a separate chunk.

Step-by-step solution

  1. Wrap dynamic import.
  2. Chunk loads on demand.

Why the other options are wrong

  • A. React API.
  • B. asyncImport('./Big.vue') is not a Vue API for this; the correct choice is defineAsyncComponent(() => import('./Big.vue')).
  • D. new Component('./Big.vue') is not a Vue API for this; the correct choice is defineAsyncComponent(() => import('./Big.vue')).

Question 7Medium

What renders if the parent supplies no content for <slot>Default</slot>?

  1. Nothing
  2. An error
  3. undefined
  4. Default

Answer: D. Default

Explanation

Content inside <slot> is fallback content.

Step-by-step solution

  1. No content passed.
  2. Fallback is used.

Why the other options are wrong

  • A. Fallback content appears.
  • B. No error.
  • C. Not printed.

Question 8Medium

What does a child do to pass data to a scoped slot?

  1. Emit an event named slot from the child and have the parent listen with @slot
  2. Use provide only
  3. Bind attributes on <slot>, e.g. <slot :item="item" />
  4. Call this.$slots.data()

Answer: C. Bind attributes on <slot>, e.g. <slot :item="item" />

Explanation

Attributes on <slot> become slot props the parent receives via v-slot="{ item }".

Step-by-step solution

  1. Child binds props on slot.
  2. Parent destructures them.

Why the other options are wrong

  • A. Emit is for parent callbacks.
  • B. Not required.
  • D. Not how scoped slots work.

Question 9Hard

Which is true of <component :is="Comp">?

  1. It imports the component file automatically from the name given in the string
  2. It renders a dynamic component chosen at runtime
  3. It forces the component to be async
  4. It can only take strings

Answer: B. It renders a dynamic component chosen at runtime

Explanation

:is accepts a registered name or the component object.

Step-by-step solution

  1. Bind :is.
  2. Vue renders that component.

Why the other options are wrong

  • A. You must import or register it.
  • C. <component :is> chooses which component to render; it does not make it async.
  • D. It can take component objects too.

Question 10Hard

What is <Suspense> used for?

  1. Delaying all rendering by one tick so that state changes are batched together
  2. Server-only rendering
  3. Showing fallback content while async dependencies (like async setup) resolve
  4. Lazy CSS loading

Answer: C. Showing fallback content while async dependencies (like async setup) resolve

Explanation

It has #default and #fallback slots and handles async components and top-level await.

Step-by-step solution

  1. Wrap async component.
  2. Provide fallback slot.

Why the other options are wrong

  • A. Not a timer.
  • B. Works on client too.
  • D. It is about components.

Tip: Suspense was experimental for a long time; know the idea rather than the flags.

Practise all 10 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Vue.js topics · All topics