为了账号安全,请及时绑定邮箱和手机立即绑定

webpack加载下载自阿里巴巴iconfont字体库的字体文件出错

跟着Materliu老师用react实现画廊应用,做到导航条部分的时候使用iconfont,在样式文件中书写了以下声明:

@font-face {

font-family: "iconfont";

src: url('../fonts/iconfont.eot'); /* IE9*/

src: url('../fonts/iconfont.eot?#iefix') format('embedded-opentype'); /* IE6-IE8 */

src: url('../fonts/iconfont.woff') format('woff'); /* chrome, firefox */

src: url('../fonts/iconfont.ttf') format('truetype'); /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/

src: url('../fonts/iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */

}

结果发现字体文件加载错误。错误信息如下,有知道错在哪里么?

(unknown) ./src/fonts/iconfont.ttf Module parse failed: 

C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\src\fonts\iconfont.ttf 

Unexpected character '' (1:0)

 You may need an appropriate loader to handle this file type.

 SyntaxError: Unexpected character '' (1:0)    at Parser.pp$4.raise (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)    at Parser.pp$7.getTokenFromCode (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2756:10)    at Parser.pp$7.readToken (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2477:17)    at Parser.pp$7.nextToken (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2468:15)    at Parser.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:515:10)    at Object.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:3098:39)    at Parser.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\lib\Parser.js:902:15)    at NormalModule.<anonymous> (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\lib\NormalModule.js:104:16)    at NormalModule.onModuleBuild (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)    at nextLoader (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25) @ ./~/css-loader!./~/_autoprefixer-loader@3.2.0@autoprefixer-loader?{browsers:["last 2 versions"]}!./~/_sass-loader@6.0.6@sass-loader/lib/loader.js?outputStyle=expanded!./src/styles/App.scss 6:359-391

正在回答

2 回答

 You may need an appropriate loader to handle this file type.

配置一下loader


0 回复 有任何疑惑可以回复我~

重启一下server

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
React实践图片画廊应用(下)
  • 参与学习       25452    人
  • 解答问题       48    个

颠覆式前端UI开发框架-React,使用React打造图片画廊应用

进入课程

webpack加载下载自阿里巴巴iconfont字体库的字体文件出错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信