如何将可从Chrome调试器控制台调用的调试功能添加到Create React App?

obi*_*ahn 8 debugging google-chrome create-react-app

我使用Create React App创建了一个应用程序。

如何添加resetDatabase()可从Chrome调试控制台(或其他方式)调用的全局调试功能(例如)?

小智 2

您可以将该函数附加到全局窗口对象或某个命名空间对象。

\n\n

然后在控制台中您可以使用以下命令运行它:

\n\n

window.resetDatabase();

\n\n

Here\xe2\x80\x99s 是有关通过 componentWillMount 回调访问全局上下文的相关帖子的链接。

\n\n

如何在 React 中声明全局变量?

\n