在 Vuex 中访问 rootState getter

Accessing rootState in Vuex getter

如何在 getter 中访问 rootState

const getters = {
  getParams: rootState => {
    return rootState.route.params
  },
}

以上方法无效。这是怎么做到的?

如果此 getter 在模块中 rootState 是第三个参数。

const getters = {
  getParams: (state, getters, rootState) => {
    return rootState.route.params
  }
}