import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations'
import actions from './action'
Vue.use(Vuex)
const state = {
userinfo: {}, // 登錄信息
isLogin: '', // 是否已登錄
buttonPermission: '', // 按鈕權(quán)限對象
currentTabName: '', // 當前編輯的tab
projectId: '' // 項目id
}
export default new Vuex.Store({
state,
actions,
mutations
})
import * as types from './mutation-types'
export default {
SET_PROJECT_ID(state, { projectId }) {
state.projectId = projectId
}
}
3.賦值
this.store.state.projectId
5.監(jiān)聽
watch:{
'$store.state.projectId': function () {
let that = this
that.getDiscernList(that.objData,1)
}
}
6.main.js中引入 import store from './store'