Closed Mawster closed 6 years ago
From an example (https://codeburst.io/vuex-and-typescript-3427ba78cfa8):
// index.ts import Vue from 'vue'; import Vuex, { StoreOptions } from 'vuex'; import { RootState } from './types'; import { profile } from './profile/index'; Vue.use(Vuex); const store: StoreOptions<RootState> = { state: { version: '1.0.0' // a simple property }, modules: { profile } }; export default new Vuex.Store<RootState>(store);
We have the profile module and it works fine to inject it with @State('profile') profileState
But is there a possibility to get the RootState? like: @State('root') rootState
No, since State decorator is for mapping sub state to computed property. You should just use this.$store.state
State
this.$store.state
From an example (https://codeburst.io/vuex-and-typescript-3427ba78cfa8):
We have the profile module and it works fine to inject it with @State('profile') profileState
But is there a possibility to get the RootState? like: @State('root') rootState