コンテンツへスキップ

provideLocal

カテゴリ
エクスポートサイズ
最終変更
先週

同じコンポーネント内で値を取得するためにinjectLocalを呼び出す機能が拡張されたprovide

使用方法

vue
<script setup>
import { injectLocal, provideLocal } from '@vueuse/core'

provideLocal('MyInjectionKey', 1)
const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
</script>

型宣言

typescript
/**
 * On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
 *
 * @example
 * ```ts
 * provideLocal('MyInjectionKey', 1)
 * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
 * ```
 */
export declare const provideLocal: typeof provide

ソース

ソースドキュメント

貢献者

ZHAO Jin-Xiang
Anthony Fu

変更履歴

v12.0.0-beta.1 2024年11月21日
0a9ed - feat!: Vue 2 のサポートを削除、バンドルを最適化、クリーンアップ (#4349)
v10.5.0 2023年10月7日
cf757 - fix: provideLocal および injectLocal の Vue 2 サポート (#3464)
5d948 - feat(createInjectionState): 同じコンポーネントでの provide と inject を許可 (#3387)

MITライセンスの下でリリースされています。