Vue · Junior · Question 3 of 75
What does a Single-File Component (.vue file) contain?
<script setup>
import { ref } from "vue";
const count = ref(0);
</script>
<template>
<button @click="count++">Clicked {{ count }} times</button>
</template>
<style scoped>
button { font-weight: bold; }
</style>- ✓Correct answer: The component's logic, template and styles in one file
- 2Only the template; logic must live in a separate
.jsfile - 3A configuration file for the Vue compiler
Explanation
SFCs keep related code together. The build tool (Vite plugin) compiles <template> into a render function, processes <script setup> and scopes the styles.