第一步:在vscode中下载扩展Debugger for Chrome
第二步:点击右侧调试按钮,然后添加配置选择chrome
第三步:在launch.json中添加如下代码
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch index.html (disable sourcemaps)",
"type": "chrome",
"request": "launch",
"sourceMaps": false,
"file": "${workspaceRoot}/1/page/index.html"
}
]
}
这里解释一下file路径,最后的index.html,是你运行后浏览器打开的页面,1是你当前文件夹。
最后再从调试中选择launch index.html
大功告成
感谢您的阅读