You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i think that should exists some builtin keys like ContextKey const ContextKey: InjectionKey<SetupContext> = Symbol('tt')
so we can get context (store, router) through injection like
import { InjectionKeys } from 'vue'
function useProduct() {
const { root: { $store } } = inject(InjectionKeys.Context)
// do something with $store
}
this can make more modular "use" functions
The text was updated successfully, but these errors were encountered:
It's easy to use and a bonus point is that it's strongly typed if you use TS.
The inject('$router') way is also strongly typed but only if you import 'vue-router', which you'd probably not do... so it's slightly inferior.
i think that should exists some builtin keys like ContextKey
const ContextKey: InjectionKey<SetupContext> = Symbol('tt')
so we can get context (store, router) through injection like
this can make more modular "use" functions
The text was updated successfully, but these errors were encountered: