【发布时间】:2021-02-12 13:17:21
【问题描述】:
我正在尝试在同一文件夹中启动 HTML 多个文件,并在 Visual Studio Code 的 Chrome 中打开它们(不是每个文件的新窗口)。我尝试了这个解决方案:Multiple Launch Files in Visual Studio Code,但我想,我错过了一些东西。
在开始新的调试会话之前,我总是会收到关闭当前调试会话的消息。
这是我的文件夹的 launch.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": [
{
"name": "Chrome1",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file":"${file}"
},
{
"name": "Chrome2",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file": "${file}"
},
{
"name": "Chrome3",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file": "${file}"
}
],
"compounds": [
{
"name": "Chrome1/Chrome2/Chrome3",
"configurations": ["Launch Chrome","Launch Chrome","Launch Chrome"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
谢谢!
【问题讨论】:
-
您是否使用实时服务器来启动文件?
-
是的。我熟悉实时服务器。但我有兴趣调试多个文件。
-
没有名为
Launch Chrome的启动配置,所有3个配置都使用同一个文件 -
即使我将配置更改为: "compounds": [ { "name": "Chrome1/Chrome2/Chrome3", "configurations": ["Chrome1","Chrome2","Chrome3" ], "preLaunchTask": "${defaultBuildTask}" } ];没有好事发生。
-
另外,如果我错了,请纠正我,但 ${file} 不表示当前文件。因此,如果我更改当前/活动文件,那么 ${file} 的值也应该如此?