useScopeId

Commons
stable

Reads the Vue SFC scope ID from the current component instance and returns it as an attribute object. Used to ensure that teleported or dynamically-created DOM nodes receive the same scoped-CSS attribute as their parent component, so that scoped style rules continue to match across teleport boundaries.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

API

Valeurs de retour

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

scopeId
An object whose single key is the Vue-generated scope attribute (e.g. { "data-v-abc123": "" }). Spread via v-bind on the teleported element to restore scoped CSS. Undefined when the component has no scope ID (e.g. in a plain JS context).

Usage

Exemples

Extraits de code prêts à coller.

Apply scope to a teleported overlay

vue

Spread on a programmatic createElement call

vue