Chrome JavaScript调试 - 如何在页面刷新或通过代码断开之间保存断点? [英] Chrome JavaScript Debugging - how to save break points between page refresh or break via code?

查看:536
本文介绍了Chrome JavaScript调试 - 如何在页面刷新或通过代码断开之间保存断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用Chrome和它的JavaScript调试器时,每次重新加载我的页面/脚本时,我的断点都会丢失,我必须在弹出的窗口中找到脚本文件,找到我的断点的代码行,点击添加它等。

When using Chrome and it's JavaScript debugger, every time I reload my page / scripts, my breakpoints are lost and I have to go find the script file in the pop-up, find the line of code for my break point, click to add it, etc.

有没有办法保存这些断点,即使在页面刷新(其他调试器我使用过这样做)后,它也会中断?

Is there a way to save these breakpoints so it breaks even after a page refresh (other debuggers I have used do this)?

或者,我的JavaScript代码中是否有干净的方式我可以输入一些内容来告诉chrome开始跟踪(暂停一行)?

Alternatively, is there a clean way in my JavaScript code I can type something to tell chrome to start tracing (to pause on a line)?

推荐答案

您可以将

debugger;

在大多数JavaScript环境中中断。他们肯定会坚持下去。如果您正在使用这些,那么有一个可以调试生产环境的调试器和console.log调用的最小化器是非常好的。

to break in most of the JavaScript environments. They will persist for sure. It's good to have a minifier that rids the debugger and console.log calls for the production environment, if you are using these.

在最近的Chrome浏览器版本中,是控制面板顶部的保留日志选项,旁边的过滤器。在旧版本中,右键单击空控制台窗口将带来该选项(保存登录导航)。当您没有console.log语句或硬编码的调试器调用时,这很方便。

In the recent versions of Chrome browser, there is a "Preserve Log" option on the top of the console panel, next to the filters. In the older versions, right clicking on the empty console window will bring that option ("Preserve log upon navigation"). It's handy when you don't have console.log statements or hard-coded debugger calls.

更新:我在github上找到了一个名为烟囱,它需要一个文件并删除所有的console.log调用。它给出了如何清除调试器调用的好主意。

update: I found a tool on github, called chimney, which takes a file and removes all the console.log calls. it gives a good idea about how to remove debugger calls.

这篇关于Chrome JavaScript调试 - 如何在页面刷新或通过代码断开之间保存断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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