Vue controls visibility with v-if, v-else-if, and v-else. Unlike CSS display:none, v-if does not render the branch when false—children are destroyed and recreated when toggling.
v-if vs v-show
v-if— true conditional; good for expensive subtrees or rare branchesv-show— toggles CSSdisplay; element stays mounted; better for frequent toggles
Patterns
<p v-if="loading">Loading…</p>
<p v-else-if="error">{{ error }}</p>
<ul v-else>...</ul>
Keep chains readable—extract subcomponents when branches grow, similar to avoiding deeply nested ternaries in React.
Self-check
- When is
v-showpreferable tov-if? - What happens to child component state when
v-ifbecomes false?