【问题标题】:how to use Chrome Debugger with live server in Visual Studio Code如何在 Visual Studio Code 中将 Chrome 调试器与实时服务器一起使用
【发布时间】:2020-04-20 17:20:39
【问题描述】:

我目前正在使用Visual Code Studio,并且我安装了Live ServerDebugger for Chrome 扩展。

我正在测试一个简单的 .html 文件,以查看在我新切换到的 VS Code 上的调试效果。

我将 launch.json 文件中的 url 更改为 "url": "http://localhost:5500" 以使用 Live Server 端口。

现在的问题:当我点击上线时,浏览器会打开http://127.0.0.1:5500/debug.html,但是当我点击 F5 进行调试时,我只会重定向到http://127.0.0.1:5500。有没有办法在调试模式下重定向到完整路径,而不是每次手动调整 url 到 http://127.0.0.1:5500/'File Path' ?如果可能,该页面将在新标签而不是新的 chrome 窗口中打开。

任何建议请我在我的设置中缺少什么?我关注了多个线程和文档,但仍然无法使其工作,例如 thisthis

【问题讨论】:

    标签: debugging visual-studio-code vscode-debugger


    【解决方案1】:

    也许您应该定义.html 文件。

    这是一个例子:

    {
        "port": 8181,
        "host": "0.0.0.0",
        "root": "/public",
        "open": false,
        "ignore": "scss,my/templates",
        "file": "index.html",
        "wait": 1000,
        "mount": [
            ["/components", "./node_modules"],
            ["/image", "./myImageFolder"]
        ],
        "logLevel": 2
    }
    

    希望对您有所帮助!如果还有什么需要请告诉我,我可以帮你解决。

    【讨论】:

    • 这是实时服务器配置文件。我正在做一些谷歌搜索,它看起来像是在调试端的 launch.json 上设置规则。我不确定你的方法我应该如何根据你的建议更新我的设置
    • .json文件中,添加一个名为"file"的键,并赋值"index.html"
    • 我就是这样做的。但我希望它能够动态检测文件名,而不是每次都自己手动编写。而不是使用“file”:“login.html”或“file”:“datatable.html”......它会像“file”:“{my_current_file_in_debug}”
    • 签出 Visual Studio 代码 (code.visualstudio.com/docs/editor/variables-reference) 中的变量。我认为你的情况是${file}
    猜你喜欢
    • 2018-02-09
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 2016-08-31
    • 2016-09-16
    • 1970-01-01
    • 2016-12-27
    相关资源
    最近更新 更多