Vue · Junior · Question 32 of 75
How do you use a child component in <script setup>?
<script setup>
import UserCard from "./UserCard.vue";
</script>
<template><UserCard name="Ann" /></template>- ✓Correct answer: Import it; imported components are available in the template automatically
- 2Import it and add it to a
components: {}option - 3Register it globally with
app.component- local use is not possible
Explanation
With <script setup> there is no separate registration step. Global registration via app.component() also works but prevents tree-shaking and hides dependencies.