Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Vue 3 v-show Directive

Vue 3 v-show Directive

Vue3 Built-in Directives Vue 3 Built-in Directives


v-show The directive is used to toggle an element's visibility based on the truthiness of an expression. It controls the element's show/hide through the CSS display property.


Basic Explanation

v-show The directive decides whether the element is shown based on the truthiness of the bound expression. Whether the condition is true or false, the element is rendered into the DOM; only its visibility is controlled via CSS.


Difference Between v-show and v-if

Feature v-show v-if
Rendering Method Always rendered into the DOM, only controlling show/hide Rendered when the condition is true, not rendered when false
Toggle Performance Low toggle cost (only changes CSS) High toggle cost (needs to create/destroy elements)

Use Cases

1. Frequently Toggle Visibility

When an element needs to show/hide frequently, using v-show gives better performance:

Example


Vue3 Built-in Directives Vue 3 Built-in Directives