access store outside of component vuejs
30,705
Try to import 'store' with curly brackets
import {store} from '../store/index'
store.getters.appSettings
Another option is to access from the vue property
import Vue from 'vue'
Vue.store.getters.appSettings
Author by
capiono
Updated on January 09, 2020Comments
-
capiono over 4 years
I have a file for configuring my OpenID Connect authentication
export const authMgr = new Oidc.UserManager({ userStore: new Oidc.WebStorageStateStore(), authority: **appsetting.oidc** })
I want to access my state in order to get the value of appsetting.
I did this:
import store from './store' const appsetting = () => store.getters.appsetting
but my appsetting is always returning undefined
what I my missing?
Store:
app.js
const state = { appsetting: appsetting, } export { state }
getters.js
const appsetting = state => state.appsetting export { appsetting }
index.js
export default new Vuex.Store({ actions, getters, modules: { app }, strict: debug, plugins: [createLogger] })
when I print the value of
store.getters
, it returns this:{ return __WEBPACK_IMPORTED_MODULE_2__store__["a" /* default */].getters; }
No the actual store objects