vue使用vuex大体结构
程序员文章站
2023-02-02 20:48:32
store1.js index.js main.js ......
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')