visual-studio-code - 无法在vscode中运行网页

标签 visual-studio-code

我是 vscode 新手。

我的问题可能看起来很愚蠢。

我有 3 个文件:index.htmlindex.jsindex.css

我安装了 chrome 调试扩展,但不知道如何运行我的代码

如果我想运行/调试我在 chrome 中收到这个错误

chrome ERR_CONNECTION_REFUSED

我确定问题出在 launch.json 文件上。在这里:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

我想要的是要启动的index.html

最佳答案

由于您没有运行任何网络服务器以使其在本地主机上查看,因此您不能将 url 设置为 localhost 而是简单地告诉 chrome 从您的工作区打开文件。

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "${workspaceFolder}/index.html", // <-- This should be the path of the index.html file relative to the workspace
            "webRoot": "${workspaceFolder}"
        }
    ]
}

关于visual-studio-code - 无法在vscode中运行网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62611349/

相关文章:

visual-studio-code - 默认情况下 VSCode 预览 Markdown

r - 在带有 conda 环境的 Visual Studio Code 中使用 R

c++ - Visual Studio Code - 远程调试 Bazel C++ - 无法读取文件'vscode-remote ://dev- file

typescript - 如何使用多个 tsconfig 文件(编译器选项冲突)?

java - 如何为 vscode 终端定义命令/变量?

visual-studio-code - 一次开发和调试多个 VSCode 扩展

visual-studio-code - vscode : Open file instead of previewing file from quick open

spring-boot - 如何让 VS Code 识别嵌套的 gradle 项目?

visual-studio-code - VSCode 键绑定(bind)配置中 "acceptSelectedSuggestion"和 "acceptAlternativeSelectedSuggestion"之间的差异

visual-studio-code - 在 VS Code 多终端设置上运行命令