Vuex中namespaced的作用

446 阅读1分钟

使用

 export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
 }
this.$store.commit("userInfo/setUserInfo",userInfo)

作用

  • vuex中的store分模块管理,需要在store的index.js中引入各个模块,为了解决不同模块命名冲突的问题,将不同模块的namespaced:true,之后在不同页面中引入getter,actions,mutations时,需要加上所属的模块名