使用CDN时如何调用React Logger功能



我正在创建自己的文件来学习反应。为了简化我使用CDN的内容,到目前为止,一切都没有流动。我不知道如何将Redux-Logger中间件提供给我的Redux.Applymiddleware fn。

我应该在这里替换/* logger */string用?

<!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>

如果检查redux-logger的UMD Bundler Config,该配置在其Github repo中:https://github.com/logrocket/logrocket/redux-logger/blob/blob/master/master/rollup.config。JS#L33-您会看到它们将UMD捆绑包的模块命名为reduxLogger。因此,您应该如下访问它:

const logger = window.reduxLogger.logger

相关内容

  • 没有找到相关文章