如何知道哪个文件在Chrome控制台中定义了一个js全局变量? [英] How to know in which file that defined a js global var in chrome console?
问题描述
例如,变量 Native
如何找出哪个文件和行变量是使用谷歌浏览器控制台定义的? code>(来自MooTools)已在全球范围内定义。我想知道在哪个文件中使用谷歌浏览器控制台定义了这个变量。使用chrome:
$ b
- 打开Web Inspector
- 显示控制台并检查您要搜索的变量是否存在(例如:Native < kbd> Enter )
- 点击资源面板
- 输入
Native =
,var本地
或Native =
在右上方的搜索字段中 - 您已获得结果!
这里, Native = $ c只有一个结果$ c>搜索。结果会自动突出显示,并打开相应的文件。在我的示例中,您可以看到
Native
声明位于 mootools.core.js
,第12行。
编辑:2015年3月(感谢)
您现在需要使用右上角的三点按钮找到搜索所有文件
选项。
How to find out which file and line a variable was defined in using google chrome console?
For example, the variable Native
(from MooTools) has been defined in global scope. I want to know in which file that defined this variable using google chrome console.
Using chrome :
- Open the Web Inspector
- Show the console and check if the var you're searching for exists (ex : Native Enter)
- Click on the Resources panel
- Enter
Native=
,var Native
orNative =
in the top right search field - You've got your result !
Here, there's only one result for the Native=
search. The result is automatically highlighted, and the corresponding file opened. In my example, you can see the Native
declaration was in mootools.core.js
, line 12.
EDIT: March 2015 (thanks to TML)
The top right search field doesn't exist anymore, in latest Chrome versions.
Instead of, click on Show drawer
in the top right corner (or hit Esc), and select the Search
tab that just appeared in the bottom of your screen:
EDIT: November 2015 (thanks tzvi)
You now need to use the three-dot button in the top right corner to find a Search all files
option.
这篇关于如何知道哪个文件在Chrome控制台中定义了一个js全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!