我正在使用Visual Studio代码,并希望在web浏览器中调试当前打开的HTML文件,在本例中为Microsoft Edge。我的项目文件夹是本地安装的web服务器(http://localhost)的webroot。我已经安装了VS代码扩展"Microsoft Edge Tools for VS Code“,并创建了一个包含以下内容的launch.json配置:
{
"configurations": [
{
"name": "Launch Microsoft Edge and open the Edge DevTools",
"request": "launch",
"type": "vscode-edge-devtools.debug",
"webRoot": "${workspaceFolder}",
"url": "http://localhost/${relativeFile}"
}
]
}
但是,当我启动这个调试器时,Microsoft Edge打开的URL是http://localhost/$%7BrelativeFile%7D
,因此似乎没有解析变量${relativeFile}。
我如何解决这个问题并实现我的目标?
发布于 2021-11-10 11:16:10
relativeFile将引用相对于workspaceFolder的当前打开的文件。您需要指定在VS Code中打开的文件夹的路径,webroot
{
"configurations": [
{
"name": "Launch Microsoft Edge and open the Edge DevTools",
"request": "launch",
"type": "vscode-edge-devtools.debug",
"webRoot": "${workspaceFolder}" // "${workspaceFolder}/src"
"url": "http://localhost/${relativeFile}"
}
]
}
参考:- https://code.visualstudio.com/docs/editor/variables-reference
每条评论更新:-
%7B和%7D是{
和}
的ASCII码。在launch.json中,检查VScode的右下角,看看它的编码是什么?应为UTF-8
https://stackoverflow.com/questions/69912160
复制相似问题