暂停/中断 javascript 的执行以进行调试,但仅限于某些 javascript 文件

发布于 2024-11-29 13:08:33 字数 316 浏览 0 评论 0原文

是否有浏览器支持暂停执行/单步执行代码,但仅限于某些文件或区域?我正在使用 jQuery 和其他几个库,并且在 99% 的情况下我对单步执行它们的代码不感兴趣,因为这是我的代码错误的。我的所有代码都在我的脚本文件中,其他库单独包含。

如果我使用暂停按钮,我往往会发现我很快就会进入 jquery 的某些部分,其中包含我不理解或需要理解的代码。如果我多次单击“单步执行”按钮,有时会进入脚本中的某个点,有时则不会。

我可以手动单击代码的每一行来添加断点,但这将非常乏味,而且我无法轻松取消暂停执行。如果有一个浏览器可以让您选择多行并单击一下即可向所有行添加断点,那么这将是一个很好的选择。

Do any browsers support pausing execution / stepping through code, but only for certain files or regions? I'm using jQuery and several other libraries, and I'm not interested in stepping through their code in 99% of cases, as it is my code that is wrong. All my code is in my script file, other libraries are included separately.

If I use the pause button, I tend to find that I am very quickly taken to some part of jquery with code I don't understand or need to understand. If I click the step into button a lot, I sometimes get taken to a point in my script, sometimes not.

I could manually click every single line of my code to add a breakpoint, but this would be extremely tedious, and I couldn't un-pause execution easily. If there is a browser that lets you select multiple lines and add breakpoints to all of them in one click, that would be a great alternative, though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

紫罗兰の梦幻 2024-12-06 13:08:33

Chrome 开发者工具中的一些新功能可以帮助您获得进入新代码库的良好切入点。事件侦听器断点将允许您在给定的事件处理程序处暂停执行:

There are some new features in the Chrome developer tools that can help you get a good entry point into a new code base. Event listener breakpoints will let you pause execution at a given event handler:

高速公鹿 2024-12-06 13:08:33

自从我五年前提出这个问题以来,情况发生了变化。 Chrome(可能还有其他浏览器)有一个选项“Blackbox script”。如果您发现自己在库(例如 jQuery)中暂停,请右键单击,选择“Blackbox 脚本”,当您将来单步执行代码时,您将自动跳过该文件中的所有行。

Things have changed since I asked the question 5 years ago. Chrome (and possibly other browsers) have an option "Blackbox script". If you find yourself paused inside a library, e.g. jQuery, right click, choose "Blackbox script" and you will automatically skip over all lines in that file when you are stepping through the code in future.

谁把谁当真 2024-12-06 13:08:33

这就是步入/结束/步出的用途。如果程序因调试而停止,并且您正在单步执行并看到即将进入 jQuery 函数(或任何您想跳过的其他内容),则单击“step over”。如果您陷入了某种想要立即退出的情况,请单击“退出”。

只需在要开始调试的位置设置断点,然后使用此处的步骤功能来控制要停止查看的内容。

This is what step in/over/out is for. If the program is stopped for debugging, and you're stepping through and see that you're about to descend into a jQuery function (or anything else you want to skip over) you click "step over". If you got into something which you want to get right back out of, you click "step out".

Simply set the breakpoint where you want to begin debugging, and use the step functions from there to control what you're stopping to take a look at.

錯遇了你 2024-12-06 13:08:33

将断点放在所需的 javascript 文件中以及您要检查代码的位置!
这将让你跳过跳转到其他文件,并且你将能够在同一个 JS 文件中继续

Put the break points in the desired javascript files and where you want to inspect your code!
Press this will let you skip the jumping to other files and you will be able to continue in the same JS file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文