Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vuex-API-数据获取中示例代码错误 #88

Open
yangangzhang opened this issue May 15, 2020 · 0 comments
Open

Vuex-API-数据获取中示例代码错误 #88

yangangzhang opened this issue May 15, 2020 · 0 comments

Comments

@yangangzhang
Copy link

大佬您好,看您文章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
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant