Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular项目生产版本在导入google字体时遇到问题_Angular_Angular Material_Google Fonts - Fatal编程技术网

Angular项目生产版本在导入google字体时遇到问题

Angular项目生产版本在导入google字体时遇到问题,angular,angular-material,google-fonts,Angular,Angular Material,Google Fonts,我有一个基于最新版本8.2.9的angular项目。在测试环境中使用ngserve时,Google字体可以完美地工作。但是,当我在生产服务器上发布项目时,不会加载字体 style.scss @import url('https://fonts.googleapis.com/css?family=Nunito:200,600'); @import url('https://fonts.googleapis.com/icon?family=Material+Icons'); 由于上述问题,材质图标

我有一个基于最新版本8.2.9的angular项目。在测试环境中使用
ngserve
时,Google字体可以完美地工作。但是,当我在生产服务器上发布项目时,不会加载字体

style.scss

@import url('https://fonts.googleapis.com/css?family=Nunito:200,600');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
由于上述问题,材质图标无法加载,如图所示


但是,当我将上述字体加载语句从全局样式
style.scss
移动到
app.component.scss
时。很好用!有什么原因不适用于全球风格吗?我在这里发现了类似于此问题的内容

只是在
标记中将google字体包含到index.html中,而不是任何scss或css文件

它还将用于生产构建


另一个解决方案是,当我从angular.json文件中的样式数组中删除材质css文件时。您的
angular.json
是否在
style
选项中包含全局样式表?@G.Tranter yes“style.scss”作为数组与材质css文件一起包含。正如我在前面的评论中所说,当我删除材质css文件时,效果很好。这似乎是一个功能性的解决方法,但它并没有解释一开始发生了什么。你知道问题本身是什么吗?