在模块导航方面,模块风格混杂



我有两个模块,admin和front模块。我有两个无主题的文件,每个模块都不同。当我从一个模块导航到另一个模块时,它们正在混合。但如果我直接转到一个模块,样式是可以的,当我导航到一个模块时就会发生这种情况。

管理组件.ts

@Component({
selector: "app-admin",
templateUrl: "./admin.component.html",
styleUrls: ["./admin.component.css","./admin-theme.less"],
encapsulation: ViewEncapsulation.None
})

前部组件.ts

@Component({
selector: "app-front",
templateUrl: "./front.component.html",
styleUrls: ["./front.component.css","./front-theme.less"],
encapsulation: ViewEncapsulation.None
})

angular.json

"styles": [
"node_modules/ng-zorro-antd/ng-zorro-antd.min.css",             
"src/styles.css" 
],

admin.component.htmlfront.component.html上,我只有路由器出口。我用的是ng zorro。

ViewEncapsulation.None将所有CSS移动到DOM中,而不是组件级。试着去掉那条线,检查它是否适合你的情况。

阅读有关ViewEncapsulation的更多信息。

最新更新