【发布时间】:2018-06-24 05:21:48
【问题描述】:
我正在使用 ionic 3 构建一个混合移动应用程序,其中一个要求是用户具有动态更改工具栏颜色的能力。页面渲染后,html 是这样的:
<div id="divICanControl"> //this div i can control
<div> //but this one is generated by the framework and this is the div that change the background color of the toolbar
</div>
</div>
我尝试执行以下操作:
document.getElementById('divICanControl').childNodes[0].style.backgroundColor = this.someColor;
它偶尔会起作用,但它在 vscode 中产生了以下错误:
[ts] Property 'style' does not exist on type 'Node'.
它停止了应用程序的构建。
我现在正在寻找使用 angular 操作 dom 的正确方法。
感谢您的帮助,请记住,我是 Angular 5 和打字稿的新手。
【问题讨论】:
标签: angular typescript dom visual-studio-code ionic3