Accessing rootState in Vuex getter

后端 未结 1 1098
误落风尘
误落风尘 2021-02-11 14:34

How do you access rootState in getters?

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

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-11 15:00

    If this getter is in a module rootState is the third arguments.

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

    0 讨论(0)
提交回复
热议问题