我正在创建文件以了解自己的反应。 为简化起见,我使用了cdn,直到现在一切都变得顺畅。 我不知道如何为Redux.applymiddleware fn提供redux-logger中间件。
我应该将/ *此处* /字符串替换为什么吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React step by step</title>
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/redux@4.0.1/dist/redux.js" crossorigin></script>
<script src="https://unpkg.com/redux-thunk@2.1.0/dist/redux-thunk.js" crossorigin></script>
<script src="https://unpkg.com/redux-logger@3.0.6/dist/redux-logger.js" crossorigin></script>
<script type="text/javascript" src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
</head>
<body>
<div>Open your Dev tool! (F12)</div>
</body>
<script type="text/babel" >
const reducer = (state = {}, action) => {
return state;
}
//const myMiddleware = Redux.applyMiddleware( /* logger here */)
const store = Redux.createStore( reducer/*, myMiddleware*/ );
store.dispatch({ type: 'FOO'});
const currentState = store.getState();
console.log(currentState)
</script>
</html>
答案 0 :(得分:2)
如果您检查redux-logger
的{{3}}捆绑程序配置,该配置位于他们的GitHub存储库中:UMD-您会看到他们将UMD捆绑包的模块命名为{{ 1}}。因此,您应该按以下方式访问它:
reduxLogger