如何在Google Chrome DevTools的lambda调用中设置断点? [英] How to set a breakpoint at a lambda call in Google Chrome DevTools?

查看:187
本文介绍了如何在Google Chrome DevTools的lambda调用中设置断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用启用了JavaScript源地图的Babel和Google Chrome开发者工具。给定此代码

I use Babel and Google Chrome Developer Tools with JavaScript source maps enabled. Given this code

function myFunc(elements) {
  return elements
    .map(element => element.value)
    .filter(value => value >= 0);
}

如何在执行lambda函数时暂停执行 element => element.value ?如果我在 .map(element => element.value)的行设置一个断点,它只会在执行map时暂停,但不会在执行lambda函数时暂停。

how can I pause execution at execution of lambda function element => element.value? If I set a breakpoint at line of .map(element => element.value) it will only pause when map is executed, but not when the lambda function is executed.

推荐答案

此功能终于可用(至少在谷歌Chrome 58中)。单击要调试的lambda行的行号(此处为第3行)。然后通过单击激活lambda中的标记(此处为第二个)。此外,我在这里禁用了第一个标记,它将暂停在地图调用(不是lambda):

This feature is finally available (at least in Google Chrome 58). Click on the line number of the line of your lambda you like to debug (here line 3). Then activate the marker in your lambda (here the second) by clicking it. Further, I disabled the first marker here, which would pause on the map call (not the lambda):

当程序运行并命中断点时,它会暂停,您可以检查变量:

When your program runs and hits the breakpoint, it will pause and you can inspect variables:

这篇关于如何在Google Chrome DevTools的lambda调用中设置断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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