Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/provideLocal.md
1---2category: State3---45# provideLocal67Extended `provide` with ability to call `injectLocal` to obtain the value in the same component.89## Usage1011```vue12<script setup>13import { injectLocal, provideLocal } from '@vueuse/core'1415provideLocal('MyInjectionKey', 1)16const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 117</script>18```1920## Type Declarations2122```ts23export type ProvideLocalReturn = void24/**25* On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.26*27* @example28* ```ts29* provideLocal('MyInjectionKey', 1)30* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 131* ```32*/33export declare function provideLocal<T, K = LocalProvidedKey<T>>(34key: K,35value: K extends InjectionKey<infer V> ? V : T,36): ProvideLocalReturn37```38