瀏覽器警告Failed to decode downloaded font 系統頁面字體圖標加載不出來 問題總結


1.后台攔截,此時警告后往往是localhost:8080一類的地址

  解決方法:maven放行,或者springSecurity放行

maven放行:在pom文件中(網上抄來的)

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
             <exclude>static/**/*.woff</exclude>
             <exclude>static/**/*.woff2</exclude>
             <exclude>static/**/*.ttf</exclude>
        </excludes>
     </resource>
     <resource>
         <directory>src/main/resources</directory>
         <filtering>false</filtering>
         <includes>
              <include>static/**/*.woff</include>
              <include>static/**/*.woff2</include>
              <include>static/**/*.ttf</include>
         </includes>
     </resource>

 

2. 前端問題 ,此時警告后往往跟的是url類型的,如application.....

可能是打包問題,我自己是跟着B站一個教程做的Vue+SpringBoot+ElementUI的系統

在vue項目中的webpack.base.conf.js中的module里,將原有的url-loader注釋掉,用file-loader解析這些字體文件即可

//注釋的原代碼(url-loader)
/*{
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      },*/
//用file-loader 
      {
        //是為了解析字體的模塊,遇到“eot|svg|ttf|woff|woff2”,用file-loader模塊解析,正則表達式
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        loader: 'file-loader'
      }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM