学习代码的时候,一定要动手实践,否则根本学不会!
import { createStore, applyMiddleware } from "redux";
import { combineReducers } from "redux"
//引入中间键盘
import logger from "redux-logger"
import thunk from "redux-thunk"
// 两个reducer 我开始测试 combineReducer
function nameReducer(state = { "name": "action" }, action) {
const type = action.type;
switch (type) {
case "get":
return state;
default:
return state;
}
}
function CountReducer(state = 10, action) {
const type = action.type;
switch (type) {
case "add":
state++;
return state;
case "minus":
state--;
return state;
case "asyncAdd":
// 我打印这个就是想看下,它咋接收参数的!
console.log(action);
state++;
return state