getCurrentInstance

Commons
stable

Asserts that the call is made inside a Vue component setup function and returns the current internal instance. Throws a descriptive [Origam] error when called outside a component context.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

name
requis
string
The caller name used in the thrown error message, e.g. "useColor".
message
string
Optional custom error message. Defaults to "must be called from inside a setup function".

API

Valeur de retour

La valeur retournée par cet util.

The current Vue component internal instance. Never null — throws if the context is absent.

Usage

Exemples

Extraits de code prêts à coller.

Guard a composable to setup context

typescript