有没有办法在JS变量上设置断点? [英] Is there a way to set a breakpoint on a JS variable?

查看:74
本文介绍了有没有办法在JS变量上设置断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的javascript文件中有一个变量,该变量一直在变化,我无法弄清楚为什么或何时对其进行变化.

I have a variable in my javascript file that keeps getting changed and I can't figure out why or when it is getting changed.

当变量更改时,是否可以设置断点或其他方法?我目前在Mac上使用Safari,但也安装了Chrome,因此,如果Chrome开发者工具中有更简便的方法,我也可以这样做.或者,当然,如果有一个单独的工具也可以进行这种出色的调试.

Is there a way to set a breakpoint or something when the variable gets changed? I'm currently using Safari on a Mac but also have Chrome installed so if there is an easier way in Chrome Developer Tools I can do that as well. Or of course if there is a separate tool that allows for this type of debugging that is awesome as well.

这甚至有可能吗?如果可以,怎么办?

Is this even possible? If so how?

非常感谢.

推荐答案

我还没有使用Mac或Safari,但肯定可以通过Chrome的调试器来实现.

I haven't used Mac or Safari but it should still definitely be possible with Chrome's debugger.

在页面上单击鼠标右键,然后选择检查"以调出开发人员工具.从选项卡中,选择源",并确保在左侧的索引上选择了您的页面.可以使用断点和其他调试工具.

Alt-click on the page and choose "Inspect" to bring up Developer Tools. From the tabs, choose "Sources" and make sure your page is selected on the index on the left. Breakpoints and other debugging tools are available there.

这篇关于有没有办法在JS变量上设置断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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