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>

Explanation

SFCs keep related code together. The build tool (Vite plugin) compiles <template> into a render function, processes <script setup> and scopes the styles.

Further reading

Problem with a question

Vue · Junior · question 3

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz