我的代码:
document.querySelector(".myTabs .line")[0].style.left = '30%' ;
我有错误
undefined is not an object (evaluating 'document.querySelector(".myTabs .line")[0].style')
我如何从 Controller 更改 css 样式?
最佳答案
document.querySelector
将返回第一个匹配类型为 Element
的元素。您需要将其转换为 HTMLElement
。试试这个:
let elm = <HTMLElement>document.querySelector(".myTabs .line");
elm.style.left = '30%'
关于angular - 从 Controller Ionic 2 更改元素样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44802728/