准备工具
在 VS Code 中安装 Debugger for Chrome 插件。
配置 lanch.json
{
// 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",
"sourceMaps": true,
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceRoot}"
}
]
}
配置完成后,在 Angular 工程目录输入命令 ng serve 启动项目,然后就可以打断点调试了。
调试
在 VS Code 中按 F5 进入调试模式,打开 Chrome 刷新页面,就进入断点。