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

Vue 3 v-memo Directive

Vue 3 v-memo Directive

Vue3 Built-in Directives Vue 3 Built-in Directives


v-memo The directive is used to memoize a template's subtree, deciding whether to skip updates by specifying a dependency value array.

Available only in Vue 3.2+.


Basic Explanation

v-memo The directive allows you to memoize part of a template. It expects a fixed-length dependency value array. If each value in the array is the same as during the last render, the update of the entire subtree will be skipped.


Basic Syntax

Example

 

  Never update


Use Cases

1. Long List Optimization

v-memo is especially useful when processing large lists, as it can skip list items that do not need updating:

Example


Difference Between v-memo and v-once

Instruction Purpose Applicable scenarios
v-once Never update Content is completely static and needs no updates
v-memo No update when dependencies are unchanged Content needs updating only when specific dependencies change

Vue3 Built-in Directives Vue 3 Built-in Directives