uni-app引入自定义图标后报错

uni-app引入自定义图标后报错

按照uni-app官网https://uniapp.dcloud.io/component/uniui/uni-icons引入自定义图标后,报错信息如下:

18:23:01.393 Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
18:23:01.395 ModuleNotFoundError: Module not found: Error: Can't resolve './iconfont.ttf?t=1643100394872' in 'E:\project\patrol_system'
18:23:01.395     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\webpack\lib\Compilation.js:925:10
18:23:01.397     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\webpack\lib\NormalModuleFactory.js:401:22
18:23:01.397     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\webpack\lib\NormalModuleFactory.js:130:21
18:23:01.399     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\webpack\lib\NormalModuleFactory.js:224:22
18:23:01.399     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\neo-async\async.js:2830:7
18:23:01.400     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\neo-async\async.js:6877:13
18:23:01.400     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\webpack\lib\NormalModuleFactory.js:214:25
18:23:01.400     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\Resolver.js:213:14
18:23:01.405     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\Resolver.js:285:5
18:23:01.405     at eval (eval at create (D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
18:23:01.407     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:44:7
18:23:01.407     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\Resolver.js:285:5
18:23:01.407     at eval (eval at create (D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:13:1)
18:23:01.407     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\Resolver.js:285:5
18:23:01.407     at eval (eval at create (D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:25:1)
18:23:01.415     at D:\software\executepackage\HBuilderX.3.2.9.20210927\HBuilderX\plugins\uniapp-cli\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:67:43

解决:
修改iconfont.css中src的引用路径如下(改成了绝对路径):

@font-face {
  font-family: "iconfont";
  src: url('~@/static/iconfont.ttf?t=1643100394872') format('truetype');
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值