为单独的页面自定义正文的背景颜色
Customize the background color of body for seperate pages
所以我正在使用 angular 5,我正在尝试自定义主页正文的背景颜色,但不允许将该颜色传递到下一页。
使用 ng-deep 我有点让这个工作正常,因为如果用户刷新页面它就可以工作。那么我如何停止将白色的主体颜色传递到下一页并在不刷新页面的情况下显示灰色
提前致谢
您可以从组件访问它:
export class HomePageComponent implements AfterViewInit {
constructor(private elementRef: ElementRef){}
ngAfterViewInit(){
this.elementRef.nativeElement.ownerDocument.body.style.backgroundColor = 'red';
}
}
所以我正在使用 angular 5,我正在尝试自定义主页正文的背景颜色,但不允许将该颜色传递到下一页。
使用 ng-deep 我有点让这个工作正常,因为如果用户刷新页面它就可以工作。那么我如何停止将白色的主体颜色传递到下一页并在不刷新页面的情况下显示灰色
提前致谢
您可以从组件访问它:
export class HomePageComponent implements AfterViewInit {
constructor(private elementRef: ElementRef){}
ngAfterViewInit(){
this.elementRef.nativeElement.ownerDocument.body.style.backgroundColor = 'red';
}
}