Menu
CoddyTech

Importing Components

Part of the Fundamentals section of Coddy's Vue journey. Lesson 31 of 55.

A parent can render another SFC by importing it in script setup. The component name becomes a template tag, so this parent renders the content of BookNotice.vue.

import BookNotice from './BookNotice.vue';
// Parent template: <main><BookNotice /></main>

The child file supplies its own template and optional state or styles. Use a relative path that matches the actual filename, including case. This separates a focused UI piece from the page that arranges it without requiring global registration.

challenge icon

Challenge

Easy

Create WelcomePanel.vue with a section containing an h2 reading Repair cafe and a paragraph reading Bring one broken item. Import and render it inside main#result in App.vue.

Try it yourself

<!doctype html><html><head><meta charset="UTF-8"><title>Vue practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals