标签:als redux ted actions this 路由 switch state action
在学习了redux基本教程后,课程参考如下网址:https://www.redux.org.cn/docs/introduction/CoreConcepts.html,开始着手练习
1.首先编写一个actions
export const CHANGE_VALUE = ‘CHANGE_VALUE‘;
function infoInputChange(data) {
return (dispatch) => {
dispatch({
type: CHANGE_VALUE,
data: {
...data,
},
});
};
}
export { infoInputChange };
2.编写一个reducers
import * as actions from ‘../actions/patient.js‘;
const initialState = {
patientSelectedRowKeys: [],
};
export default function index(state = initialState, action = {}) {
switch (action.type) {
case actions.CHANGE_VALUE:
return Object.assign({}, state, {
patientSelectedRowKeys: action.data,
});
default:
return state;
}
}
3.在reducers 的index.js中填加如下内容
标签:als redux ted actions this 路由 switch state action
原文地址:https://www.cnblogs.com/web-zxq/p/10699844.html