在VS Code中调试js
先安装两个插件
- debugger for chrome
- live server
创建一个index.html文件,创建一个index.js文件
在index.html中引入index.js文件
在index.js文件中打断点
创建launch.json文件
环境选择chrome
修改launch.json如下
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "chrome 调试",
"url": "http://localhost:5500",
"webRoot": "${workspaceFolder}"
}
]
}
点击调试即可