实际使用代码,将高阶函数变成正常函数,在第一个return位置打断点
const getters = {getReadOnly: function(state, parameter, { App }) {return (row, prop) => {const shareUserID = App.fileInfo.shareUserID;return getReadOnly(row, prop, shareUserID);}},
根据堆栈找到上层函数调用代码,在vuex内部(vuex.esm.js)
function registerGetter (store, type, rawGetter, local) {if (store._wrappedGetters[type]) {if ((process.env.NODE_ENV !== 'production')) {console.error(("[vuex] duplicate getter key: " + type));}return}store._wrappedGetters[type] = function wrappedGetter (store) {return rawGetter(local.state, // local statelocal.getters, // local gettersstore.state, // root statestore.getters // root getters)};
}
可见,第一个参数是local(本store)的state,第二个参数是本store的getters,第三个参数是全局store的state(按照下方初始化store的代码,就是modules的{name:state}对象),第四个参数是全局store的getters(所有modules的getters)
const store = new Vuex.Store({modules: modules, // all your modules automatically imported :)strict: debug == 'false',plugins: debug == 'true' ? [logger] : [] // set logger only for development
});