vue使用vuex大体结构_輕微_前端开发者

store1.js

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

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

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

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

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

new Vue({
store,
render: h => h(App)
}).$mount('#app')

» 本文来自:前端开发者 » 《vue使用vuex大体结构_輕微_前端开发者》
» 本文链接地址:https://www.rokub.com/73817.html
» 您也可以订阅本站:https://www.rokub.com
赞(0)
64K

评论 抢沙发

评论前必须登录!