Vue.js & Composition API (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the `<script setup>` syntax sugar?
junior LevelvueBasic
In Simple Words:
<script setup> is the compiled syntactic sugar for using the Composition API inside Single-File Components (SFCs):
- No boilerplate: Top-level variables, functions, and imports are automatically exposed to the template without an explicit
export default { setup() { return { ... } } }. - Better runtime performance: Compiles directly into the component's render function, avoiding the overhead of proxying the setup return object.
- First-class TypeScript support with
defineProps,defineEmits, anddefineModel.