Chrome devtools:无需切换到“源"选项卡即可进入调试器 [英] Chrome devtools: Drop into debugger without switching to Sources tab

查看:57
本文介绍了Chrome devtools:无需切换到“源"选项卡即可进入调试器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将 debugger 语句在我的JavaScript源中打开了Chrome devtools,它将停止执行,因此我可以从控制台以交互方式浏览当前上下文.真的很棒.

If I put the debugger statement in my JavaScript source with the Chrome devtools open, it'll stop execution so I can interactively explore the current context from the console. It's really awesome.

但不幸的是,它还会切换到源"选项卡,并显示发生 debugger 语句的行.大多数时候,我想输入JavaScript命令,因此必须手动切换回控制台"选项卡.

But unfortunately it will also switch to the Sources tab and display the line where the debugger statement happened. Most of the time, I want to type JavaScript commands, so I have to manually switch back to the Console tab.

我可以避免切换选项卡并停留在控制台"选项卡中吗?

Can I avoid the tab-switching and stay in the Console tab?

还是我用错了?

推荐答案

这样做是有原因的-并且,只要由于断点或 debugger 语句而导致代码停止,您就可以d通常想真正看到执行已停止的 where .因此,开发人员工具切换到脚本/源"选项卡,这是主要浏览器之间的常见行为,还可能显示局部变量,调用堆栈等.

There's a reason for that - and is that whenever the code has stopped, because of a breakpoint or a debugger statement, you'd usually want to actually see where the execution has stopped. So, the developer tools switches to the Scripts/Sources tab, and this is a common behaviour among the major browsers, that may also show the local variables, the call stack and so on.

您能做的最好的事情就是保持控制台框架始终处于打开状态,这样您就可以开始工作了.只需按Esc或单击左下角的第二个图标.这就是我通常要做的.

The best thing you can do is to keep the console frame always open, so you're ready to work. Just press Esc or click on the second icon on the lower left corner. That's what I usually do.

当您希望从键入的命令中获得较大响应时,请切换到控制台"选项卡.

Switch to the Console tab when you expect to get a large response from the command you type.

这篇关于Chrome devtools:无需切换到“源"选项卡即可进入调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆