VsCode中的node调试
和网页调试
学习
node调试
我们在VsCode中新建一个js文件,写一段测试代码并且打开终端,切换到调试控制台
界面(打开终端的快捷键是:Ctrl+~
)
在vscode中按F5
,进入调试,我们选择node.js调试
选中node.js调试将会执行js代码,结果会打印在
调试控制台
断点调试
在第二行代码中加断点
点击F5
,选择node.js调试,光标拖到我们定义的变量hello,可以看到当前hello的值为“hello”
再次点击
F5
网页调试
若要支持网页调试,需安装Debugger for Chrome,如下是基本配置方式
{
// 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": [
{
"name": "Launch localhost", "type": "chrome",
"request": "launch",
"url": "http://localhost/index.html",
"webRoot": "${workspaceFolder}/wwwroot"
},
{
"name": "Launch index.html",
"type": "chrome",
"request": "launch",
"file": "${workspaceFolder}/index.html"
},
]
}
调试(F5)的时候选择Chrome,使用Chrome调试时,需要起http-server服务
http-server服务起完后,选择调试界面,F5就可以了
结尾
我是圆圆,如果我的文章对你的学习成长有所帮助,欢迎 点 赞 👍 支持,您的 点 赞 👍 支持是我进行创作和分享的动力!
如果有问题可以留言评论或者私信我,我都会一一解答~笔芯🤞