import { createStore } from 'redux'
/**
* state存储, 初始化
*/
const states = {
user: {}
};
/**
* action方法
*/
const actions = {
setUser: (state, value) => {
state.user = value
}
};
/**
* 构建Store实列
*/
const Store = createStore(
(state, action) => {
actions[action.type] && actions[action.type](state, action.value);
return state
},
states
);
export default Store
redux优化switch书写方式成Object
于 2021-02-04 15:42:27 首次发布