简体   繁体   English

Chrome Inspector中的Javascript调试:变量未在手表和控制台中显示,但在悬停时可以检查

[英]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.

相关问题 在Chrome控制台中调试javascript - debugging javascript in Chrome console 在Chrome控制台中进行Javascript调试 - Javascript Debugging in Chrome Console JavaScript全局变量在Google Chrome控制台中显示为未定义 - JavaScript global variable is shown as undefined in Google Chrome console 如何为可在控制台中检查的角度服务创建变量? - How do I create variables for angular services that can be inspected in the console? 在Javascript控制台中控制Chrome Web Inspector? - Control Chrome Web Inspector in Javascript console? 使用 Json Encode 返回 Javascript 时,PHP 变量显示在控制台中 - PHP variables are shown in the console when returned to Javascript with Json Encode class 未显示在铬元素检查器中 - class is not shown in elements inspector in chrome 是否可以从外部javascript访问控制台命令行API(例如Firebug或Chrome Inspector控制台的$$和traceAll)? - Can I access the console Command line API (like $$ and traceAll from Firebug or Chrome Inspector Console) from an external javascript? Chrome控制台JavaScript中是否显示所有错误? - Are all errors shown in the Chrome console JavaScript errors? 在页面加载时调试Chrome中的ReactJs - 在使用控制台时,这个以及其他所有内容都是未定义的 - Debugging ReactJs in Chrome on page load - this and everything else is undefined when using console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM