在 PrimeFaces 6.2+ 中使用 FontAwesome 5.x
Using FontAwesome 5.x with PrimeFaces 6.2+
我正在检查这个问题:
How to use Font Awesome from webjars.org with JSF
蚂蚁这个问题:
FontAwesome with PrimeFaces
及其答案
您好,我想使用 https://fontawesome.com/changelog/latest 5.5 版本
的新图标
在我的 pom.xml
文件项目中...
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/font-awesome -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.5.0</version>
</dependency>
在我的 web.xml
文件中
<!-- Fontawesome -->
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
在我的 facelet .xhtml 中
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/templates/template.xhtml">
<ui:define name="body">
<h:outputScript library="webjars" name="font-awesome/5.5.0/js/all.js"/>
...
<p:spacer width="10"/>6
<h:outputText styleClass="fas fas-map"/>7
<h:outputText styleClass="fa fa-venus-mars fa-icon-custom" />
<h:outputText styleClass="fa fa-female fa-icon-custom" />
<h:outputText styleClass="fa fa-male fa-icon-custom" />
注意:我正在使用 fas
和 fa
,但两者都不起作用
如我图片所示,所有图标都失效了
如何解决?
PF 6.2.12 和 PF 6.3 中添加了使用 FontAwesome 5 的功能。看到这张票并提交它增加了能力:
https://github.com/primefaces/primefaces/issues/4276
https://github.com/primefaces/primefaces/commit/c28c0bccc615bffb99c30825c8c7d8084c3a72da
在 web.xml:
中关闭默认 PF 支持
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>false</param-value>
</context-param>
更新您的pom.xml。
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.8.2</version>
</dependency>
为 JSF 使用正确的 WebJars CSS。
<h:outputStylesheet library="webjars" name="font-awesome/5.8.2/css/all.min-jsf.css" />
<h:outputStylesheet library="webjars" name="font-awesome/5.8.2/css/v4-shims.min-jsf.css" />
注意: 您必须更改 "fa",因为现在 Font Awesome 已分为不同的类别,例如 "fas" "fab" 等。请参阅 documentation here.
我正在检查这个问题: How to use Font Awesome from webjars.org with JSF 蚂蚁这个问题: FontAwesome with PrimeFaces 及其答案
您好,我想使用 https://fontawesome.com/changelog/latest 5.5 版本
的新图标在我的 pom.xml
文件项目中...
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/font-awesome -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.5.0</version>
</dependency>
在我的 web.xml
文件中
<!-- Fontawesome -->
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
在我的 facelet .xhtml 中
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/templates/template.xhtml">
<ui:define name="body">
<h:outputScript library="webjars" name="font-awesome/5.5.0/js/all.js"/>
...
<p:spacer width="10"/>6
<h:outputText styleClass="fas fas-map"/>7
<h:outputText styleClass="fa fa-venus-mars fa-icon-custom" />
<h:outputText styleClass="fa fa-female fa-icon-custom" />
<h:outputText styleClass="fa fa-male fa-icon-custom" />
注意:我正在使用 fas
和 fa
,但两者都不起作用
如我图片所示,所有图标都失效了
如何解决?
PF 6.2.12 和 PF 6.3 中添加了使用 FontAwesome 5 的功能。看到这张票并提交它增加了能力:
https://github.com/primefaces/primefaces/issues/4276
https://github.com/primefaces/primefaces/commit/c28c0bccc615bffb99c30825c8c7d8084c3a72da
在 web.xml:
中关闭默认 PF 支持<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>false</param-value>
</context-param>
更新您的pom.xml。
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.8.2</version>
</dependency>
为 JSF 使用正确的 WebJars CSS。
<h:outputStylesheet library="webjars" name="font-awesome/5.8.2/css/all.min-jsf.css" />
<h:outputStylesheet library="webjars" name="font-awesome/5.8.2/css/v4-shims.min-jsf.css" />
注意: 您必须更改 "fa",因为现在 Font Awesome 已分为不同的类别,例如 "fas" "fab" 等。请参阅 documentation here.