Webstorm:“无法解析目录" [英] Webstorm: "Cannot Resolve Directory"
问题描述
这开始困扰我,我想关闭或修复它.所以 Webstorm 在它的 HTML 解析器中有一个很好的功能,它会尝试解析应该引用项目中文件的字符串中的目录.例如:
This is starting to bug me and I'd either like it turned off or fixed. So Webstorm has a sweet feature in it's HTML parser that will attempt to resolve directories in strings that are supposed to reference a file in your project. For example:
Webstorm 是正确的.我的前端代码都在 /app
中,但我的服务器在根目录的 app 中提供文件,所以在 web 上下文中 /app
实际上只是 /代码>.另一方面,这种行为也会影响我的角度模板:
Webstorm is correct. My front end code is all in /app
but my server serves up files in app on the root, so in the web context /app
is actually just /
. As a side, this behavior also impacts my angular templates:
和我的 angular-ui 路线(我想它也可以用于常规的角度路线).
and my angular-ui routes (I imagine it would do that for regular angular routes as well).
有没有办法改变 webstorm 以将 /app
视为根,所以这是一个有用的功能?如果没有,有没有办法禁用它?我尝试进入检查员,但找不到选项:
Is there a way that I can change webstorm to treat /app
as the root so this is a useful feature? If not, is there a way I can disable this? I tried going into the inspector, but couldn't find an option for it:
不,它不是 XML 格式的...我试过了.
And no, it's not the XML one... I tried.
感谢帮助.谢谢...
推荐答案
要对项目中的非根文件夹进行文件引用,您需要将该目录标记为资源.为此,请转到设置">目录",然后从右侧面板中选择您的资产根文件夹.然后通过单击文件浏览器上方的按钮将其标记为资源根.
To make file references to a non-root folder in your project, you'll need to mark that directory as a Resource. To do this, go to Settings > Directories and select your asset root folder from the right-hand panel. Then mark it as Resource Root by clicking the button above the file browser.
在 Jetbrains 文档中,资源根目录使 WebStorm 能够完成所选文件夹下资源的相对路径.这意味着您应该在包含您想要引用的所有资源(例如样式、脚本等)的文件夹上使用 Resource Root.
From the Jetbrains documentation, a Resource Root enables WebStorm to complete relative paths to resources under the selected folder. This means that you should use Resource Root on a folder that holds all the resources you would like to refer to (e.g. styles, scripts, ...).
这篇关于Webstorm:“无法解析目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!