<script setup> là syntactic sugar cho Composition API — tất cả code bên trong tự động expose ra template mà không cần return.
- Gọn hơn: không cần
export default, không cầnreturn - Hiệu năng tốt hơn: compiler tối ưu hóa tốt hơn
- TypeScript integration tốt hơn
defineProps,defineEmits,defineExposethay cho options props/emits
Lưu ý: biến và function trong <script setup> khác file KHÔNG cần export — tự exposed.
<script setup> is syntactic sugar for Composition API — all top-level bindings are automatically exposed to the template without needing return.
- Less boilerplate: no
export default, noreturn - Better performance: compiler optimizations
- Better TypeScript integration
defineProps,defineEmits,defineExposereplace option-based equivalents
Pitfall: unlike regular setup(), there is no return — everything is auto-exposed.