Cre*_*tix 5 css styling mime-types angular-components angular7
当我重新加载有角度的子组件时,页面变白并且出现错误
拒绝应用来自[URL]的样式,因为它的MIME类型('text / html')不是受支持的样式表MIME类型,并且启用了严格的MIME检查。
因此,只要我通过单击更改routerLink所有内容的按钮来浏览页面即可。
我仅production mode遇到此错误,因此在使用时ng serve可以重新加载页面,并且没有收到任何错误,并且在中Developer Tools我还可以看到中的所有文件Source tab,而当我在其中检查页面时却不是这种情况。production mode
我已经
变了
<link rel="stylesheet" href="styles.9eca5df2f679ed98933c.css">
Run Code Online (Sandbox Code Playgroud)
至
<link rel="stylesheet" type="text/css" href="styles.9eca5df2f679ed98933c.css">
Run Code Online (Sandbox Code Playgroud)建立我的项目跟vendorChunk=true在我angular.json
评论了每个相关的HTML和CSS
删除了我的样式表中的所有评论
设置encapsulation: ViewEncapsulation.None在父母和孩子身上
签<base href="/">入我index.html <head> tag并将其更改为<base href="./">,否则将无法正常工作
我想这里没有样式表,[URL]但我不知道为什么以及如何指定相关样式表的URL,因为styleUrls: ['./dashboard.component.css']在@Component-Decorator中,当我在production mode(--prod)中构建项目时,显然不起作用。
顺便说一下,我不使用任何外部样式表,因为这可能是我搜索此问题时发现错误的原因。
仅在具有以下路由的子组件上会发生此错误:
/<parent>/:id/<child>
Run Code Online (Sandbox Code Playgroud)
导航至
this.router.navigate(['../server/' + guild.id + "/dashboard"], { relativeTo: this.route });
Run Code Online (Sandbox Code Playgroud)
在每个浏览器中
我将不胜感激