我有一个用于配置OpenID Connect身份验证的文件
export const authMgr = new Oidc.UserManager({
userStore: new Oidc.WebStorageStateStore(),
authority: **appsetting.oidc**
})
我想访问我的状态以获得appsetting的值。
我这样做了:
import store from './store'
const appsetting = () => store.getters.appsetting
但我的appsetting总是返回undefined
我错过了什么?商店:
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]
})
当我打印store.getters
的值时,它会返回:
{
return __WEBPACK_IMPORTED_MODULE_2__store__["a" /* default */].getters;
}
没有实际的商店对象
答案 0 :(得分:23)
尝试导入'存储'用大括号
import {store} from '../store/index'
store.getters.appSettings
另一种选择是从vue属性访问
import Vue from 'vue'
Vue.store.getters.appSettings