springboot項目中ttf和woff字體圖標頁面無法顯示

瀏覽器控制檯報錯如下:

Failed to decode downloaded font: http://127.0.0.1:8081/fonts/element-icons.woff
index:1 OTS parsing error: incorrect file size in WOFF header
index:1 Failed to decode downloaded font: http://127.0.0.1:8081/fonts/element-icons.ttf
index:1 OTS parsing error: incorrect entrySelector for table directory

解決辦法

在網上找到了不下於4種解決方法,只有下面一種可行。 在pom.xml的build節點下添加

<resources>
    <resource>
        <directory>${project.basedir}/src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
            <exclude>static/js/element-ui/fonts/**</exclude>
        </excludes>
    </resource>
    <resource>
        <directory>${project.basedir}/src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
            <include>static/js/element-ui/fonts/**</include>
        </includes>
    </resource>
</resources>

注意:directory是 ${project.basedir}/src/main/resources

百度其他的幾種方式皆無效,給我幹自閉了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章