Eclipse:忽略“未定义的 CSS 类”警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31804675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:46:19  来源:igfitidea点击:

Eclipse: Ignore "Undefined CSS class" warning

csseclipsevalidationwarnings

提问by waterplea

I use Spring and have found this answer to similar question, however it not at all satisfactory since it requires changing project structure: Get Eclipse to recognise CSS included via context in Spring MVC project

我使用 Spring 并找到了类似问题的答案,但是它并不令人满意,因为它需要更改项目结构: Get Eclipse to identify CSS contains via context in Spring MVC project

So the question is, can I somehow set Eclipse to ignore "Undefined CSS class" warning.

所以问题是,我可以以某种方式将 Eclipse 设置为忽略“未定义的 CSS 类”警告。

It's not just about Spring, I might have some CSS classes I use in JavaScript that are not present in CSS spreadsheet or any other reason. The warning is shown on every element on html that uses css class that it cannot find, say:

这不仅仅是关于 Spring,我可能有一些我在 JavaScript 中使用的 CSS 类,这些类没有出现在 CSS 电子表格或任何其他原因中。警告显示在 html 上使用找不到的 css 类的每个元素上,例如:

<div class="js-something">Something</div>

This class is not going to be defined in .css file since it is only used in JavaScript. Same thing with Spring where .css is connected with:

这个类不会在 .css 文件中定义,因为它只在 JavaScript 中使用。与 Spring 相同的事情,其中​​ .css 与:

<link href="<c:url value='/css/style.css'/>" rel="stylesheet" type="text/css" />

Or in AngularJS project where html files are added with ng-include. This warning is really barely helpful, it probably should be even disabled by default. I've looked all through Eclipse settings but couldn't find any way to ignore this kind of warnings. Can anybody help me get rid of those?

或者在使用 ng-include 添加 html 文件的 AngularJS 项目中。这个警告实际上几乎没有帮助,默认情况下甚至应该禁用它。我已经查看了所有 Eclipse 设置,但找不到任何方法来忽略此类警告。有人可以帮我摆脱这些吗?

回答by waterplea

Allright, I've found it. Funnily enough, it is under "Validation" if you edit project preferences, but not in overall preferences, that's why I couldn't find it when searching preferences by "Validation".

好的,我找到了。有趣的是,如果您编辑项目首选项,它在“验证”下,而不是在整体首选项中,这就是为什么我在通过“验证”搜索首选项时找不到它。

In project preferences: Web Resources -> Validation -> CSS

项目首选项中:Web Resources -> Validation -> CSS

In overall preferences: Web -> HTML Files -> Web Resources -> CSS

总体偏好中:Web -> HTML Files -> Web Resources -> CSS

Finally my projects are no longer riddled with yellow markers.

最后,我的项目不再充斥着黄色标记。