useLazy

Commons
stable

Controls whether a component's content has been booted into the DOM. Content is rendered on first activation and optionally destroyed when the component closes again (eager: false). Used by Dialog, Menu, Tooltip and any overlay that should avoid rendering markup before it is first opened.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

props
requis
{ eager: boolean }
When eager is true the content is rendered immediately regardless of the active state, bypassing lazy mounting entirely.
active
requis
Ref<boolean>
Reactive open/visible state of the component. The composable watches this to boot the content on first activation.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

isBooted
Flips to true the first time active becomes true, then stays true unless eager is false and onAfterLeave is called.
hasContent
True when the content should be in the DOM: isBooted || eager || active. Gate your content slot with v-if="hasContent".
onAfterLeave
Call this on the leave-transition after-leave hook. Resets isBooted to false when eager is false, removing the content from the DOM after the closing animation completes.

Usage

Exemples

Extraits de code prêts à coller.

Lazy-mount an overlay

vue

Eager rendering (always in DOM)

vue