tryOnMounted
Commons
stable
Call a function when the component mounts, or immediately when called outside a Vue component lifecycle. Falls back to nextTick when sync is false and no lifecycle target is found.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- fnrequisTFn
- The function to execute. Called with `onMounted()` when a lifecycle instance is active, or called synchronously/via nextTick outside one.
- syncbooleantrue
- When true (default), fn is called synchronously outside a component. When false, fn is deferred with `nextTick`.
- targetany
- Optional Vue component instance to bind the lifecycle to, forwarded to `onMounted(fn, target)` when provided.
API
Valeur de retour
La valeur retournée par cet util.
- No return value. Side-effectful: schedules or calls fn.
Usage
Exemples
Extraits de code prêts à coller.
Safe use inside and outside a component