Vue.js · Function
provide
provide() makes a value available to descendant components. inject() retrieves it by key, including values provided at app level.
Last updated
Syntax
provide<T>(key: InjectionKey<T> | string, value: T): void
inject<T>(key: InjectionKey<T> | string, defaultValue?: T): T | undefined
inject<T>(key: InjectionKey<T> | string, defaultValue: () => T, treatDefaultAsFactory: true): TIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
inject()app.provide()InjectionKeyreadonly()computed()hasInjectionContext()