浏览器警告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'
      }

 

posted @ 2021-05-07 01:10  毕竟是家黑店  阅读(5147)  评论(1编辑  收藏  举报