BeginnerCoder

Lesson 21 — Dynamic components

Swap components by name

The special <component :is="…"> tag renders whichever component you give it, and switches when that value changes. Keep your components in an object and pick one by key — that is how tabs and step-by-step wizards are built.

<component :is="steps[current]" />

Why it matters: one placeholder can show any of many views, without a long chain of v-if.

Want it another way?
Task

Render the current tab with <component :is>. It should show "Profile page", then "Settings page" after Swap.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Vue.js Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.