diff --git a/src/api/composition-api.md b/src/api/composition-api.md index afc9086a8d..a770a3731d 100644 --- a/src/api/composition-api.md +++ b/src/api/composition-api.md @@ -135,6 +135,12 @@ function provide(key: InjectionKey | string, value: T): void function inject(key: InjectionKey | string): T | undefined // with default value function inject(key: InjectionKey | string, defaultValue: T): T +// with factory +function inject( + key: InjectionKey | string, + defaultValue: () => T, + treatDefaultAsFactory: true +): T ``` Vue provides an `InjectionKey` interface which is a generic type that extends `Symbol`. It can be used to sync the type of the injected value between the provider and the consumer: