File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export declare class Store<S> {
1515 readonly state : S ;
1616 readonly getters : any ;
1717
18- install ( app : App , injectKey ?: InjectionKey < Store < any > > ) : void ;
18+ install ( app : App , injectKey ?: InjectionKey < Store < any > > | string ) : void ;
1919
2020 replaceState ( state : S ) : void ;
2121
@@ -45,7 +45,7 @@ export declare class Store<S> {
4545
4646export function createStore < S > ( options : StoreOptions < S > ) : Store < S > ;
4747
48- export function useStore < S = any > ( ) : Store < S > ;
48+ export function useStore < S = any > ( injectKey ?: InjectionKey < Store < S > > | string ) : Store < S > ;
4949
5050export interface Dispatch {
5151 ( type : string , payload ?: any , options ?: DispatchOptions ) : Promise < any > ;
Original file line number Diff line number Diff line change 1+ import { InjectionKey } from "vue" ;
12import * as Vuex from "../index" ;
23
34namespace StoreInstance {
@@ -138,6 +139,14 @@ namespace UseStoreFunction {
138139 a : string
139140 }
140141
142+ const key : InjectionKey < string > = Symbol ( 'store' )
143+
144+ const storeWithKey = Vuex . useStore ( key )
145+ storeWithKey . state . a
146+
147+ const storeWithKeyString = Vuex . useStore ( 'store' )
148+ storeWithKeyString . state . a
149+
141150 const storeWithState = Vuex . useStore < State > ( )
142151 storeWithState . state . a
143152
You can’t perform that action at this time.
0 commit comments