简体   繁体   English

在 Chrome 调试器中访问 object 个变量(VueJS 调试)

[英]Accessing object variables in Chrome debugger (VueJS debugging)

I am developing VueJS / Express applications, getting into more advanced web dev than I've done before.我正在开发 VueJS/Express 应用程序,进入比我以前做过的更高级的 web 开发。 I use VSCode, and develop the back end and front end in the same project.我使用VSCode,在同一个项目中开发后端和前端。 I am able to use VSCode debugger for the back end work, and use Chrome debugger for the front end.我能够使用 VSCode 调试器进行后端工作,并使用 Chrome 调试器进行前端工作。

VSCode works great. VSCode 工作得很好。 End of that story.那个故事的结尾。

Chrome is powerful, but quirky. Chrome 功能强大,但也很古怪。 I end up debugging what is going on with the Chrome debugger quite a bit.我最终用 Chrome 调试器调试了很多东西。 Add to that the inscrutable Vue internals, which are always popping up, adding another level that has to be plowed through (or ignored).再加上神秘莫测的 Vue 内部结构,它们总是会突然出现,从而增加了另一个必须深究(或忽略)的层次。 But the biggest issue I have is that I cannot inspect instance variables in component scripts, only variables that are local to the function that the breakpoint is in. This reduces my process to doing a lot of one-time console.log() statements, where one is in search of just a quick inspect of a 'this.[anything]' instance variable.但我遇到的最大问题是我无法检查组件脚本中的实例变量,只能检查断点所在的 function 的本地变量。这将我的过程减少为执行大量一次性 console.log() 语句,人们只是在寻找对“this.[anything]”实例变量的快速检查。

I've been just putting up with this for months, but lately doing some refactoring it's slowed my progress to a crawl, so I'm looking to see if there is a way I can overcome this obstacle and speed up my debugging process.几个月来我一直在忍受这个问题,但最近进行了一些重构,这让我的进度变得缓慢,所以我想看看是否有办法克服这个障碍并加快我的调试过程。

Anyone have a suggestion?有人有建议吗? Is there a way to set Chrome to enable inspecting object variables?有没有办法设置 Chrome 以启用检查 object 变量? Is there a more efficient debugging method or tool for Vue front end dev? Vue前端开发有没有更高效的调试方法或者工具?

Other than this, the combining of front end and back end code into one project has been great.除此之外,将前端和后端代码合并到一个项目中非常棒。 VSCode rocks. VSCode 摇滚。

I have found a workaround for Vue, which is to place a breakpoint in the Watch section, using a button in the UI.我找到了 Vue 的解决方法,即使用 UI 中的按钮在 Watch 部分放置一个断点。 In this breakpoint, a Watch in Chrome debugger has access to 'this' variables.在此断点中,Chrome 调试器中的 Watch 可以访问“this”变量。 Fellow dev's have told me that this is a common issue they deal with all the time.开发人员告诉我,这是他们一直处理的常见问题。 When I get more understanding on the conditions that affect this scope access problem, I'll add it.当我对影响此 scope 访问问题的条件有了更多了解后,我将添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM