简体   繁体   English

无法使用 Debugger for Chrome 在 Visual Studio Code 中放置断点

[英]Can't place breakpoints in Visual Studio Code with Debugger for Chrome

I am simply trying to debug some javascript that is within my html page.我只是想调试我的 html 页面中的一些 javascript。

I setup the configuration as follows:我设置的配置如下:

but when I am debugging my html page (using the second option called "launch the div.html"), it runs but I can't set breakpoints...但是当我调试我的 html 页面时(使用名为“启动 div.html”的第二个选项),它运行但我无法设置断点......

Any ideas?有任何想法吗?

 { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "http://localhost:8080/", "webRoot": "${workspaceFolder}" }, { "type": "chrome", "request": "launch", "name": "Launch the div.html", "sourceMaps": true, "file": "${workspaceFolder}/div.html", "webRoot": "${workspaceFolder}" } ] }

It seems debugging inline JavaScript is not supported (I can't set a breakpoint either). 似乎不支持调试嵌入式JavaScript(我也无法设置断点)。 You have to separate your JS code into its own file and include it into div.html like so: <script src="div.js"></script> Now set breakpoints in your div.js and start debugging. 您必须将JS代码分离到其自己的文件中,然后像这样将其包含在div.html中: <script src="div.js"></script>现在在div.js中设置断点并开始调试。 I encountered problems when I first run debugging that breakpoints were not hit/loaded. 当我第一次运行调试时遇到断点未加载的问题。 I could solve that be clicking on the green "Restart" debug button. 我可以解决的是单击绿色的“重新启动”调试按钮。

PS: You need the Debugger for Chrome extension to be installed, but it seems you have already done that. PS:您需要安装Debugger for Chrome扩展程序,但是看来您已经完成了。

Check again with VSCode 1.39 (Sept. 2019)再次检查 VSCode 1.39(2019 年 9 月)

It does improve the UI for column breakpoints它确实改进了列断点的 UI

While debugging, VS Code now shows all the breakpoint candidate locations inline.在调试时,VS Code 现在内联显示所有断点候选位置。
This makes it easier for the user to place a breakpoint on a more accurate position.这使用户可以更轻松地在更准确的位置上放置断点。
To not clutter the UI, candidate breakpoints are only shown if there is more than one possible location on the line.为了不使 UI 混乱,仅当在线上有多个可能的位置时才会显示候选断点。

You can interact directly with inline breakpoints;您可以直接与内联断点交互; clicking to enable and disable them and invoking their context menu for more actions.单击以启用和禁用它们并调用它们的上下文菜单以进行更多操作。

内联断点:https://code.visualstudio.com/assets/updates/1_39/breakpoints.gif

Note that this feature requires support by the underlying runtime or debugger, and we expect only a few debug extensions will use this feature in the future.请注意,此功能需要底层运行时或调试器的支持,我们预计将来只有少数调试扩展会使用此功能。
For this release, Node Debug and the Debugger for Chrome support this.对于此版本,Node Debug 和 Debugger for Chrome 支持此功能。
As an example for extension authors, our Mock Debug sample "mocks" support for this.作为扩展作者的一个例子,我们的 Mock Debug 示例“模拟”对此支持。

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

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