Trung BìnhVue.js iconVue.js

Single File Component (SFC) là gì?

SFC (.vue file) gom template, script, style vào một file duy nhất — tiện lợi cho development.

Cấu trúc: <template> (HTML), <script setup> (logic), <style scoped> (CSS).

  1. scoped attribute: CSS chỉ áp dụng cho component đó, tránh conflict
  2. Compiler (Vite/webpack) parse và compile SFC thành JavaScript
  3. Hỗ trợ lang attribute: <script lang="ts">, <style lang="scss">

Pitfall: scoped CSS không ảnh hưởng lên child components — dùng :deep() nếu cần.

Xem toàn bộ Vue.js cùng filter theo level & chủ đề con.

Mở danh sách Vue.js