vscode 调试html页面s无法访问此网站 localhost 拒绝了我们的连接请求

lanuch.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": [
            {
                "type": "chrome",
                "request": "launch",
                "name": "Launch Chrome against localhost",
                "url": "http://localhost:8080",
                "webRoot": "${workspaceFolder}",
                "file": "${workspaceFolder}/index.html"
            }
        ]
    }  

这里需要注意的是Debugger for Chrom 默认生成的lanuch.json文件中,只指定了url访问路径, 如果你的项目未发布到本地web服务器当中,则无法通过配置的url路径访问html页面,因此只能通过file属性指定首页文件访问

或者将项目目录放到web服务器目录下,配置正确的url去访问,例如将helloword工程放到apache服务器的htdocs目录下,在launch.json文件中 指定正确的url访问路径 http://localhost:8080/site/helloword/index.html, 即可按快捷键F5进行自动运行调试。

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值