/** * 字典store */ const state = { sexList: [{ label: '男', value: '0' }, { label: '女', value: '1' }], // 性别列表 allDeptList: [], // 全部部门列表 companyList: [] // 公司列表 } const mutations = { CHANGE_DICT: (state, { key, value }) => { if (Object.prototype.hasOwnProperty.call(state, 'key')) { state[key] = value } } } const actions = { changeDict({ commit }, data) { return new Promise((resolve, reject) => { commit('CHANGE_DICT', data) resolve(data) }) } } export default { namespaced: true, state, mutations, actions }