v-once: render element/component một lần duy nhất — skip future updates.
Sau khi render, element được xử lý như static content:
vue
<!-- Static content không bao giờ thay đổi -->
<h1 v-once>{{ appName }}</h1>
<!-- Expensive initial render, không bao giờ update -->
<StaticBanner v-once :data="bannerConfig" />
<!-- Kết hợp với v-for — freeze sau render đầu -->
<div v-for="item in list" :key="item.id" v-once>
{{ item.name }}
</div>v-pre: skip compilation toàn bộ subtree — dùng cho content muốn hiển thị mustache syntax như raw text:
vue
<!-- Hiển thị '{{ this is NOT compiled }}' -->
<span v-pre>{{ this is NOT compiled }}</span>
<!-- Dùng trong docs/code display components -->
<code v-pre>const x = ref(0)</code>Khác nhau: v-once render rồi freeze (tốt cho performance). v-pre skip compile entirely (tốt cho mustache syntax display).
Pitfall: v-once trong component vẫn chạy setup() và reactive setup — chỉ DOM update bị skip.