Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Vue 3 & Composition API 15 mins read Free Lesson

Vue 3 Architecture & Single-File Components

Understand Vue 3 SFC anatomy with template, script setup, style scoped, and core directives (v-if, v-for, v-model).

Single-File Component (SFC) Anatomy

<script setup>
import { ref } from 'vue'

const greeting = ref('Hello, Vue 3!')
const count = ref(0)

function increment() {
    count.value++
}
</script>

<template>
    <div class="counter-card">
        <h1>{{ greeting }}</h1>
        <button @click="increment">Count is: {{ count }}</button>
    </div>
</template>

<style scoped>
.counter-card {
    padding: 1.5rem;
    border-radius: 12px;
}
</style>