Webstorm: “无法解析目录”

我开始觉得不舒服了,我想把它关掉或者修好。因此 Webstorm 在 HTML 解析器中有一个很棒的特性,它将尝试解析字符串中的目录,这些目录应该引用项目中的文件。例如:

two examples

Webstorm 是对的。我的前端代码都是在 /app,但我的服务器提供的应用程序在根文件,所以在网络上下文 /app实际上只是 /。另一方面,这种行为也会影响我的角度模板:

webstorm hates angular directive templateUrl

还有我的角度航线(我想对于常规的角度航线也是这样)。

webstorm hates angular routes templateUrl

有没有一种方法,我可以改变网络风暴,以 /app为根,所以这是一个有用的功能?如果没有,有办法让它失效吗?我试着去找检查员,但是找不到其他办法:

webstorm inspector

不,不是 XML 的那个... 我试过了。

感谢你的帮助,谢谢。

56694 次浏览

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.

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, ...).

for people using IntelliJ Ultimate:

enter image description here

In Jet Brains WebStorm Go to File-->Settings-->Left Panel Select Project-->Click on Derectories-->Middle Panel Select Resource Root-->add the folders/Directories under your Project for reference or In the Right Panel You Can see +Add Content Root choose the directories and the Apply-->OK

I had this problem on Mac and solved it by changing the directories properties.

  1. Open Preferences:

Webstorm > Preferences

  1. Go to Directories section in the Preferences

Project > Directories

  1. Add content root and Resource roots

Screenshot after adding the resources root

I think this is what most people are looking for: not changing the content root, but adding a sub-folder as 'Resource Root'.

enter image description here