Vuex: Access State From Another Module

后端 未结 6 842
走了就别回头了
走了就别回头了 2021-01-30 08:12

I want to access state.session in instance.js from records_view.js. How is this accomplished?

store/modules/instance.js

6条回答
  •  無奈伤痛
    2021-01-30 08:43

    state references local state and rootState should be used when accessing the state of other modules.

    let session = context.rootState.instance.session;
    

    Documentation: https://vuex.vuejs.org/en/modules.html

提交回复
热议问题