一、安装
1 |
npm i --save redux-logger |
二、在项目中配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import { createStore, applyMiddleware } from 'redux' import todos from './reducers' // 利用redux-logger打印日志 import { createLogger } from 'redux-logger' // 安装redux-devtools-extension的可视化工具 import { composeWithDevTools } from 'redux-devtools-extension' // 使用日志打印 const loggerMiddelware = createLogger({ collapsed: true }) const store = createStore( todos, composeWithDevTools(applyMiddleware(loggerMiddelware)) ) export default store |