部署时未加载字体 [英] Font is not loading when deployed

查看:58
本文介绍了部署时未加载字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个可在本地环境中完美加载的角度应用程序.所有样式和字体都将得到应用.但是当我部署它时,字体没有加载.无法弄清楚原因,它在控制台中未显示任何错误或警告消息.

I have created an angular app which loads perfectly fine in local environment. all the styles and fonts are getting applied. but when I deploy it the font is not loading. couldn't figure it out why, it didn't show any error or warning message in the console.

我要在 angular.json 文件中导入所有css样式,如下所示

I'm importing all the css styles in angular.json file like below

demo4.css 具有我需要的样式.我将 demo4 文件放在第一个,中间和最后一个中,什么也没发生,而且没有任何意义!

demo4.css has the styles that I need. I placed the demo4 file in the first, middle and last , nothing happened and didn't made any sense !!

在本地运行时,

部署后,

好几天我都在head头.我想念什么?

I was banging my head for days. What am I missing?

更新#1

这是我构建 ng build --prod

推荐答案

好像您遇到了这个唯一可用的解决方法是在每个使用的SCSS的 header 中添加Google字体 @import 标记.或首先从其他 css/SCSS 文件

The only workaround available is to Add Google fonts @import tag in the header of every SCSS used. Or import first the fonts from a different css/SCSS file

编辑或将字体导入index.html

EDIT Or import your font in index.html

这篇关于部署时未加载字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆