gpt4 book ai didi

visual-studio - Visual Studio "site cannot be reached localhost refused to connect"中的谷歌浏览器调试器

转载 作者:行者123 更新时间:2023-12-03 15:22:30 26 4
gpt4 key购买 nike

我目前正在尝试在 google chrome 浏览器中打开在 Visual Studio 中编写的 html 文件,并在 Visual Studio 中运行 Google Chromes 调试扩展
以下是 .json 文件,我使用的是第一个配置

 {
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
但是当它在谷歌浏览器中打开时我收到错误

This site can’t be reached

localhost refused to connect.

最佳答案

我遇到过同样的问题。

有个临时解决办法,就是加"file": "${workspaceRoot}/index.html"到 launch.json 配置。

此更改将允许您在 Chrome 浏览器中打开您的 web 应用程序,并且您将能够进行调试、断点... 然而 ,考虑到浏览器会像打开本地文件一样呈现您的项目,以及 不使用网络服务器环境。

这是 launch.json 配置文件:

{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceRoot}",
"file": "${workspaceRoot}/index.html"
}
]
}

关于visual-studio - Visual Studio "site cannot be reached localhost refused to connect"中的谷歌浏览器调试器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38738905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com