useRefs
Commons
stable
Manages a dynamic array of template refs that is reset before each update cycle. Provides an updateRef(el, i) callback designed for use with :ref in v-for loops, where Vue replaces individual refs by index. The refs array is always fresh (cleared in onBeforeUpdate) so stale elements from a previous render do not leak.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- refs
- Array of collected template refs. Each slot corresponds to the index passed to updateRef. Cleared before every update cycle to avoid stale entries.
- updateRef
- Assign to :ref in a v-for loop: :ref="(el) => updateRef(el, index)". Sets refs.value[i] = el on mount and leaves the slot undefined on unmount.
Usage
Exemples
Extraits de code prêts à coller.
Collect refs from a v-for list
Refs of child Origam components