나는 액세스하려는 state.session
에서 instance.js
에서 records_view.js
. 이것은 어떻게 이루어 집니까?
store / modules / instance.js
const state = {
// This is what I want to access in records_view.js
session: {}
};
const getters = {
sessionGetter: state => state.session
};
store / modules / records_view.js
const actions = {
getSettingsAction (context, props) {
// This is how I'm trying to access session, which doesn't work
let session = context.state.instance.session;
Api(
context,
{
noun: props.noun,
verb: 'GetRecordsViewSettings',
orgUnitKey: _.has(session, 'orgunit.key') ? session.orgunit.key : '',
data: {}
},
props.callback
);
}
};
이것은 약간의 추가 컨텍스트를위한 것입니다.
store / index.js
import Vue from 'vue';
import Vuex from 'vuex';
import * as actions from './actions';
import * as getters from './getters';
import * as types from './mutation-types';
import instance from './modules/instance';
import recordsView from './modules/records_view';
Vue.use(Vuex);
export default new Vuex.Store({
state,
actions,
getters,
mutations,
modules: {
instance,
recordsView
}
});