Vue 3 v-once Directive
v-once The directive is used to render an element or component only once; subsequent updates are skipped.
Basic Explanation
v-once The directive marks an element or component to be rendered only once. In subsequent re-renders, the element and all its children are treated as static content and skipped. This can be used to optimize update performance.
- Expected type: none (does not accept an expression)
- Purpose: renders the element and component only once; subsequent updates are treated as static content and skipped.
Use Cases
1. Static Content Optimization
When some content does not need to update, using v-once avoids unnecessary re-rendering:
Example
{{ title }}
Dynamic content: {{ dynamicContent }}
update
Vue 3 Built-in Directives