store.js 452 B

123456789101112131415161718192021
  1. // 1. 导入 Vue 和 Vuex
  2. import Vue from 'vue'
  3. import Vuex from 'vuex'
  4. // 导入用户的 vuex 模块
  5. import moduleUser from './user.js'
  6. // 2. 将 Vuex 安装为 Vue 的插件
  7. Vue.use(Vuex)
  8. // 3. 创建 Store 的实例对象
  9. const store = new Vuex.Store({
  10. // TODO:挂载 store 模块
  11. modules: {
  12. // 挂载用户的 vuex 模块,访问路径为 m_user
  13. m_user: moduleUser,
  14. },
  15. })
  16. // 4. 向外共享 Store 的实例对象
  17. export default store