Vue directives là các HTML attribute đặc biệt gắn kết reactive behavior vào DOM.
- Phổ biến nhất:
v-if/v-else/v-else-if: điều kiện render, xóa/tạo DOM thật.v-show: ẩn bằngdisplay:none, DOM vẫn tồn tại.v-for: loop render, luôn cần:key.v-model: two-way binding cho input.v-bind(:attr): bind attribute động.v-on(@event): gắn event listener.
Pitfall: v-if và v-for không nên dùng trên cùng element — v-if ưu tiên cao hơn v-for trong Vue 3 (ngược với Vue 2), dùng <template v-for> bọc bên ngoài.