File tree 2 files changed +11
-2
lines changed
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> {
15
15
readonly state : S ;
16
16
readonly getters : any ;
17
17
18
- install ( app : App , injectKey ?: InjectionKey < Store < any > > ) : void ;
18
+ install ( app : App , injectKey ?: InjectionKey < Store < any > > | string ) : void ;
19
19
20
20
replaceState ( state : S ) : void ;
21
21
@@ -45,7 +45,7 @@ export declare class Store<S> {
45
45
46
46
export function createStore < S > ( options : StoreOptions < S > ) : Store < S > ;
47
47
48
- export function useStore < S = any > ( ) : Store < S > ;
48
+ export function useStore < S = any > ( injectKey ?: InjectionKey < Store < S > > | string ) : Store < S > ;
49
49
50
50
export interface Dispatch {
51
51
( type : string , payload ?: any , options ?: DispatchOptions ) : Promise < any > ;
Original file line number Diff line number Diff line change
1
+ import { InjectionKey } from "vue" ;
1
2
import * as Vuex from "../index" ;
2
3
3
4
namespace StoreInstance {
@@ -138,6 +139,14 @@ namespace UseStoreFunction {
138
139
a : string
139
140
}
140
141
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
+
141
150
const storeWithState = Vuex . useStore < State > ( )
142
151
storeWithState . state . a
143
152
You can’t perform that action at this time.
0 commit comments