如何使用Edge浏览器在VSCode中调试Angular应用程序?-后续

4

如何使用Edge浏览器在VSCode中调试Angular应用程序? 我尝试了这里的建议,但都不起作用。 我想评论最后一个答案,但我没有50个声望来这样做,用问题回答是不礼貌的,所以我在这里提出另一个问题。

上面主题中的两个launch.json建议都不起作用,来自“Debugger for Edge”的自动生成的launch.json也是如此。 我分别尝试了它们,但都无济于事(见下文)

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "edge",
            "request": "launch",
            "name": "Launch Edge against localhost(Debugger for Edge)",
            "url": "http://localhost:4200",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug edge (Answer 1 from topic, I removed the things about Chrome was I wouldn't use that browser)",
            "type": "edge",
            "request": "launch",
            "url": "http://localhost:4200/#",
            "webRoot": "${workspaceFolder}",
            "sourceMapPathOverrides": {
                "webpack:/./*": "${webRoot}/*",
                "webpack:/src/*": "${webRoot}/src/*",
                "webpack:/*": "*",
                "webpack:/./~/*": "${webRoot}/node_modules/*"
            },

        },
        {
            "name": "ng e2e",
            "type": "node",
            "request": "launch",
            "program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
            "protocol": "inspector",
            "args": ["${workspaceFolder}/protractor.conf.js"]
        }
    ]
}

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Edge (Answer 2 from topic)",
            "type": "edge",
            "request": "launch",
            "url": "http://localhost:4200/#",
            "webRoot": "${workspaceFolder}",
            "sourceMaps": true,
            "trace": true,
            "userDataDir": "${workspaceRoot}/.vscode/edge"
        }
    ]
}

浏览器启动并显示页面(应用程序),但断点没有被命中。在VSCode中,红点变成了空心圆。
上面的launch.json应该是单独的代码块,但编辑器不允许我使用
标签。
1个回答

2
首先,请检查您的VSCode版本,我的VSCode版本如下:

enter image description here

“而且,我的Angular版本是Angular 7.1.4。
要调试客户端的Angular代码,我们需要先安装Edge浏览器的调试器扩展。
在VSCode中,点击视图菜单,选择扩展选项,检查是否已经安装了Edge浏览器的调试器扩展,并已启用它。然后,按下重新加载按钮以重启VS Code并激活扩展。”

enter image description here

在TypeScript类中设置断点后,转到Debug视图并添加调试配置:

enter image description here

保存更改并选择调试环境后,您可以按F5调试代码,就像这样:

enter image description here

参考:在 Visual Studio Code 中使用 Angular

感谢您抽出时间为我提供有关如何使用Visual Code调试Angular的教程链接。很抱歉,因为我按照该页面上的说明作为我自己介绍Angular的第一步。我确实检查了我的版本,它们与您的版本相同。但是它仍然无法触发断点。(另外,Angular忘记了先前的构建,所以我不得不进行npm安装,但这是另一个问题) - Erik Taurus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接