我在VSCode中有一個非常簡單的項目,它是鏈接到一個app.js文件的index.html文件。如何在VSCode(Visual Studio Code)中一起調試HTML和JavaScript?
當我打F5時,我想運行和調試這個迷你網站。
如何配置VSCode在瀏覽器中打開index.html,然後允許我在app.js中設置斷點,這些斷點將由我在瀏覽器中與應用程序的交互觸發?
在Visual Studio中,這會「正常工作」,因爲它啓動了它自己的Web服務器IIS Express。在VSCode中,我不確定如何設置launch.json和/或tasks.json來創建簡單的node.js Web服務器並提供index.html。
我見過調試JavaScript的應用程序的一些例子,比如這個launch.json:
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Bjarte's app",
"type": "node",
"program": "app.js",
"stopOnEntry": true,
"args": [],
"cwd": ".",
"runtimeExecutable": null,
"runtimeArguments": [],
"env": {},
"sourceMaps": false
},
{
"name": "Attach",
"type": "node",
"address": "localhost",
"port": 5858,
"sourceMaps": false
}
]
}
這將運行js文件,但我不明白我怎麼能與應用程序交互。
謝謝,這是一個有益的補充。 –