javascript / beginner
Snippet
Optimizing with v-once
The v-once directive tells Vue to render the element and its children only once. After the initial render, Vue skips updates for this specific tree, which can improve performance for truly static content.
snippet.js
1
2
3
4
5
6
<template><div v-once><h1>{{ staticTitle }}</h1><p>This will never re-render, even if staticTitle changes.</p></div></template>
vue
Breakdown
1
v-once
A directive used to mark content that should be treated as static after the first render.