[英]Javascript debugging in Chrome Inspector: variables are shown undefined in watches and console but can be inspected when hovered
While debugging AngularJS in Chrome inspector I often face the situation when I know that some variables are defined, and I can inspected them by hovering a mouse over them in Chrome inspector. 在Chrome检查器中调试AngularJS时,我经常会遇到这种情况,因为我知道已定义了一些变量,因此可以通过将鼠标悬停在Chrome检查器中来检查它们。 They also appear in 'locals' tab.
它们还会显示在“本地”标签中。 However, when I try to add them to watch tab or evaluate them in console by typing the variable name I get "undefined".
但是,当我尝试将它们添加到“监视”选项卡或在控制台中通过键入变量名称来评估它们时,我得到“未定义”。 See picture(notice variable 'xhr').
参见图片(注意变量“ xhr”)。
Can anyone explain the reason why sometimes variables are shown as undefined in watch tab and console, when they aren't actually undefined in current scope? 谁能解释为什么变量在当前作用域中实际上并非未定义的情况,但有时在监视选项卡和控制台中显示为未定义的原因? And, if it's possible, how to make watch window and console to display values of the variables correctly all the time?
并且,如果可能的话,如何使监视窗口和控制台始终显示正确的变量值? See picture(notice variable 'xhr').
参见图片(注意变量“ xhr”)。
Thanks
谢谢
Source mapped variables will not show the resolved names in the debugger, as this functionality has yet to be implemented. 源映射变量将不会在调试器中显示解析的名称,因为尚未实现此功能。 The interesting part is that the map file does contain a
names
array, containing the original names. 有趣的是,地图文件确实包含一个
names
数组,其中包含原始名称。 However, the browser has yet to use this. 但是,浏览器尚未使用它。 There was an experimental feature in Canary, but that doesn't appear to exist anymore.
金丝雀(Canary)中有一个实验性功能,但是似乎不再存在。
You can follow the display source map variable names in Developer Tools thread. 您可以在Developer Tools线程中遵循显示源映射变量名称 。
In the meantime, I recommend switching to the un-minified version of the library to debug your particular problem(s), but switch it out in production. 同时,我建议切换到该库的未精简版本以调试您的特定问题,但在生产中将其切换出去。 Not ideal I know.
我知道不太理想。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.