-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
大佬您好,看您文章Vuex-API-数据获取中示例代码中,有一处
getters: {
total (state, getters, localState, localGetters) {
// 可访问全局 state 和 getters,以及如果是在 modules 下面,可以访问到局部 state 和 局部 getters
return state.a + state.b
}
}这个地方是不是写错了?
根据源码:
store._wrappedGetters[type] = function wrappedGetter (store) {
return rawGetter(
local.state, // local state
local.getters, // local getters
store.state, // root state
store.getters // root getters
)
}代码中total的参数有错误,应该更改为:
getters: {
total (state, getters, rootState, rootGetters) {
// 可访问全局 state 和 getters,以及如果是在 modules 下面,可以访问到局部 state 和 局部 getters
return state.a + state.b
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels