<div class="colorBg">这里是内容 </span></div>
在 xxx.component.ts里面
import { ElementRef } from '@angular/core';
constructor( private el: ElementRef ) {}
ngOnInit() {
this.el.nativeElement.querySelector('.colorBg').style.background = '#fff';
}
本文介绍了在Angular7中如何通过操作DOM节点来实现样式的动态修改,主要讲解了在xxx.component.ts文件中的具体实现方法。
1342

被折叠的 条评论
为什么被折叠?



