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

Vue 3 v-if Directive

Vue 3 v-if Directive

Vue3 Built-in Directives Vue 3 Built-in Directives


v-if The directive is used for conditional rendering, deciding whether to render an element or template fragment based on the truthiness of an expression.


Basic Explanation

v-if The directive conditionally renders elements based on the truthiness of the bound expression. When the condition is true, the element is rendered into the DOM; when false, the element is not rendered.


Basic Usage

Example


Used with v-else and v-else-if

v-if can be used together with v-else-if and v-else to form a condition chain:

Example

Loading...

Load failed

Content: {{ data }}


Vue3 Built-in Directives Vue 3 Built-in Directives