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')

你可能感兴趣的:(vue使用vuex大体结构)