简体   繁体   English

调试通过Chrome控制台添加的脚本

[英]Debugging a script added via Chrome Console

I am adding some JavaScripts via Chrome's devtools' console by simply just pasting a set of code. 我仅通过粘贴一组代码即可通过Chrome的devtools控制台添加一些JavaScript。 There is no way to open that code on the Sources panel so I can debug using breakpoints. 无法在“源代码”面板上打开该代码,因此我可以使用断点进行调试。 Is there a proper way to open the code on the Sources panel that was added via console? 是否有适当的方法可以打开通过控制台添加的“源”面板上的代码?

Any other ways than adding debugger; 除了添加debugger;其他方法debugger; along with the code. 以及代码。 Or a syntax error, which then shows me the file name on the right side, which opens the code in a tab in the Sources panel. 或语法错误,然后在右侧显示文件名,这会在“源”面板的选项卡中打开代码。 Attached the two scenerios on the screenshot attached. 在随附的屏幕快照上附加了两个场景。

在此处输入图片说明

Open the devtool and open the Sources tab. 打开devtool并打开Sources选项卡。 Click on the Snippets tab on create a new snippet. 单击“片段”选项卡,以创建新片段。 Write yout code in the snippet. 在代码段中编写您的代码。 Then right click on the snippet created and click run !! 然后右键单击创建的代码段,然后单击运行! You should be able to debug from here ;) 您应该可以从这里进行调试;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM