Vue Cheat Sheet
Quick Vue 3 syntax for daily work with script setup and Composition API. This lesson covers practical patterns, syntax, and mistakes to avoid.
How to Use This Cheat Sheet
Quick Vue 3 syntax for daily work with script setup and Composition API.
Revisit deeper lessons for rationale.
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<button @click="count++">{{ count }}</button>
</template>
Minimal reactive counter SFC.
Scaffold
npm create vue@latest
npm install
npm run dev
- create-vue scaffolds Vite apps.
- ref for state.
- computed for derived.
- Pinia for shared client state.
Core Reference
Quick reference for patterns covered in this lesson.
| Item | Example | Purpose |
| ref | ref(0) | State |
| computed | computed(() => ...) | Derived |
| watch | watch(src, cb) | Effects |
| v-model | forms | Bind |
| v-for | :key | Lists |
| defineProps | props | Inputs |
| defineEmits | events | Outputs |
| Pinia | defineStore | Store |
Directives Ref
| Directive | Use |
| v-bind/: | attrs/props |
| v-on/@ | events |
| v-if | conditional |
| v-show | display toggle |
| v-for | lists |
| v-model | two-way |
Common Mistakes
- Using this sheet instead of understanding reactivity.
- Writing new apps in Vue 2 style by default.
Key Takeaways
- script setup is the default.
- Prefer computed for derived UI.
- Pinia replaced Vuex for new apps.
- Keys and a11y still matter.
Pro Tip
Remember storeToRefs when destructuring Pinia state.