Element UI + Java Web—— Failed to decode downloaded font:xxx.woff
问题描述解决方案方法一<build><resources><resource><directory>${project.basedir}/build/</directory><excludes><exclude>**/*.woff</exclude>
·
问题描述
问题分析
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
Maven 会过滤字体文件并破坏它们。
解决方案
方法一
<build>
<resources>
<resource>
<directory>${project.basedir}/build/</directory>
<excludes>
<exclude>**/*.woff</exclude>
<exclude>**/*.woff2</exclude>
<exclude>**/*.ttf</exclude>
</excludes>
<filtering>true</filtering>
<targetPath>META-INF/resources/</targetPath>
</resource>
<resource>
<directory>${project.basedir}/build/</directory>
<filtering>false</filtering>
<includes>
<include>**/*.woff</include>
<include>**/*.woff2</include>
<include>**/*.ttf</include>
</includes>
<targetPath>META-INF/resources/</targetPath>
</resource>
</resources>
</build>
方法二
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webappDirectory>target/${warExplodedDirectory}</webappDirectory>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<excludes>
<exclude>**/*.woff</exclude>
<exclude>**/*.woff2</exclude>
<exclude>**/*.ttf</exclude>
</excludes>
<filtering>true</filtering>
<targetPath>/</targetPath>
</resource>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>false</filtering>
<includes>
<include>**/*.woff</include>
<include>**/*.woff2</include>
<include>**/*.ttf</include>
</includes>
<targetPath>/</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
方法三
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
<nonFilteredFileExtension>woff</nonFilteredFileExtension>
<nonFilteredFileExtension>woff2</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
参考文章
更多推荐
已为社区贡献11条内容
所有评论(0)