You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'
import state from './state'
import mutations from './mutations'
import createLogger from 'vuex/dist/logger'
Vue.use(Vuex)
const debug = process.env.NODE_ENV !== 'production'export default new Vuex.Store({
actions,
getters,
state,
mutations,
strict: debug,
plugins: debug ? [createLogger()] : []
})
前言
vuex想必不需要我介绍很多了,这一节主要是为了填补项目没有引入vuex的问题,之后做完脚手架可以选择是否使用vuex。
因为vuex用的实在是很普遍,就不介绍细节了,我们直接搭项目。
新建文件
在
app
目录新建文件夹store
:上代码
不多说,直接上代码吧。
actions.js
:getters.js
:index.js
:mutation-types.js
:mutations.js
:state.js
:最后我们将vuex引入
app
下的index.js
就好了。如果项目非常大,还需要module来管理的话,可以按照当前规则,进行改造即可。
说明
以上两点会让代码更清晰
最后
到现在,我们就将整个项目的骨架搭好了,下一章,我们将正式开始做脚手架。
The text was updated successfully, but these errors were encountered: