Devtools打破表达 [英] Devtools break on expression

查看:77
本文介绍了Devtools打破表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当给定的Javascript表达式为true时,我想暂停所有内容。

I would like to suspend everything when a given Javascript expression is true.

我看到了条件断点,但这对我不起作用,因为那样会要求先在某个地方设置断点,或者首先根据特定条件设置断点,然后向其中添加附加条件。

I have seen conditional breakpoints, but that doesn't work for me, because that would require setting a breakpoint somewhere first, or based on a certain criterion first, and adding an additional condition to it.

我想要的是能够在任何时候断开

What I want instead is to be able to break anytime a given expression is true, wherever the place.

推荐答案

在Devtools控制台中键入以下内容:

Type the following in Devtools console:

setInterval(function() {
    if(<your condition>) {
        debugger;
    }
}, 10);

这将每10毫秒轮询一次该条件,并在满足条件时中断。

This will poll for that condition every 10 ms, and break when it is met.

您可以调整 10 ,使其更适合您。 10 ms的频率已经对处理器造成很大的压力。

You can adjust 10 to be looser if that works for you. A 10 ms frequency is already a big strain on processor.

这篇关于Devtools打破表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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