import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations'
import actions from './action'
Vue.use(Vuex)
const state = {
userinfo: {}, // 登录信息
isLogin: '', // 是否已登录
buttonPermission: '', // 按钮权限对象
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.监听
watch:{
'$store.state.projectId': function () {
let that = this
that.getDiscernList(that.objData,1)
}
}
6.main.js中引入 import store from './store'
网友评论