与redux的Devtools模块不同,该工具主要依赖浏览器插件完成。模式也比Devtools简单点。
Chrome地址(360极速模式也可以用): https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd
火狐地址: https://addons.mozilla.org/en-US/Firefox/addon/remotedev/
原来代码:
const store = createStore( reducer /* PReloadedState, */ );修改为:
const store = createStore( reducer, /* preloadedState, */window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() );那么如果你使用了Middleware,原代码是
const store = createStore( reducer, /* preloadedState, */ applyMiddleware(thunk) );怎么办?
这样修改
import {createStore, combineReducers, applyMiddleware, compose} from 'redux';const store = createStore( reducer, /* preloadedState, */compose(applyMiddleware(thunk),window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()) ); 首先要导入compose,然后再使用compose将Middleware和插件调用组合起来参考原文链接: https://github.com/zalmoxisus/redux-devtools-extension?utm_source=tuicool&utm_medium=referral
另一种Devtools模块方式介绍请移步下面文章: http://www.jianshu.com/p/a2d4c1856560
新闻热点
疑难解答