首页 > 解决方案 > DocumentRoot 和 VSCode 连接

问题描述

如何在 Visual Studio Code 中设置工作区,以便“intelephense”机制建议我自动完成从我用作 DocumentRoot (Apache) 的目录开始的路径,而不是从 VS Code 工作区目录开始?

例如,我的项目(工作区)目录称为“网站”;它包含 'public' 目录,其中包含 index.html 和 style.css 。如果,在 html 文件中,我开始输入href="./,我想在其中将文件与样式链接起来,intelephense 建议public,这是错误的!

我真正想要的是:

<link rel="stylesheet" href="./style.css">

因为具有样式的文件与链接到它的 html 文件位于同一目录中。

style.css因此,如果 intelephense在我开始输入时建议我href="./,而不是建议:,那将是正确的public

我在 VS Code 工作区文件中尝试了这段代码:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "intelephense.environment.documentRoot": "./public"
    }
}

但这并不能解决问题 - 我什至不确定这是要走的路。

标签: visual-studio-codedocument-root

解决方案


推荐阅读