v-if: xóa hoàn toàn DOM khi false — chi phí cao khi toggle thường xuyên, nhưng không render child khi không cần (lazy). v-show: chỉ toggle display:none — DOM luôn được render, chi phí thấp khi toggle.
- Dùng
v-showkhi element cần toggle thường xuyên. - Dùng
v-ifkhi điều kiện ít thay đổi, hoặc khi child component có side-effects cần tránh khởi tạo.
v-if: fully removes DOM when false — high toggle cost but skips rendering children when not needed (lazy). v-show: only toggles display:none — DOM always rendered, low toggle cost.
- Use
v-showwhen toggling frequently. - Use
v-ifwhen the condition rarely changes, or when child components have side-effects that should not be initialized.