1.首先安装
npm install --save redux-thunk
2.在store文件夹下 的index.js
import { createStore, applyMiddleware, compose } from 'redux'
import reducer from './reducer'
import thunk from 'redux-thunk'
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION__ ?
window.__REDUX_DEVTOOLS_EXTENSION__({}) : compose
const enhancer = composeEnhancers(applyMiddleware(thunk))
// const store = createStore(
// reducer,
// window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
// )
const store = createStore(
reducer,
enhancer
)
export default store;