vue使用vuex大体结构

store1.js

    const state = {}
    const mutations = {}
    const actions = {}
    const getters = {}

    export default {
        namespace: true,
        state,
        mutations,
        actions,
        getters,
   }

index.js

    import Vue from 'vue'
    import Vuex from 'vuex'
    import store1 from './store1'

    Vue.use(Vuex);

    export default new Vuex.Store({
       modules: {
         store1        
      } 
    })  

main.js

    import Vue from 'vue'
    import App from './App.vue'
    import store from './store'

    new Vue({
      store,
      render: h => h(App)
    }).$mount('#app')
posted @ 2019-10-21 22:25  Barrett_07  阅读(193)  评论(0编辑  收藏  举报