Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 财产';伪风格';不存在于类型';HTMLElement';_Javascript_Angular_Typescript_Ionic3_Pseudo Element - Fatal编程技术网

Javascript 财产';伪风格';不存在于类型';HTMLElement';

Javascript 财产';伪风格';不存在于类型';HTMLElement';,javascript,angular,typescript,ionic3,pseudo-element,Javascript,Angular,Typescript,Ionic3,Pseudo Element,我正在尝试使用Typescript修改伪元素的高度 我的IDE(vscode)中出现以下错误 这是我的密码 // select element let el: HTMLElement = document.getElementById('filter-container'); // style the height of psydo element el.pseudoStyle("before", "height", newHeight); ... 尝试el.prototype.pseudo

我正在尝试使用Typescript修改伪元素的高度

我的IDE(vscode)中出现以下错误

这是我的密码

// select element
let el: HTMLElement = document.getElementById('filter-container');
//  style the height of psydo element
el.pseudoStyle("before", "height", newHeight);
...

尝试
el.prototype.pseudoStyle(“before”,“height”,newHeight)

正如我在JavaScript中所知道的,我们不能更改伪元素,我猜TS中也是如此,因为它是一个JS超集。
非常感谢。

您不能仅在特定元素上设置伪类的样式,您可以通过更改样式表来实现:

document.styleSheets[0].insertRule('#id:hover { background-color: blue; }', 0);
document.styleSheets[0].cssRules[0].style.backgroundColor= 'blue';

HTMLElement
接口中没有
pseudoStyle
属性。这就是它在IDE中抛出错误的原因。您可以这样做
let el:any=document.getElementById('filter-container')@BasavarajBhusani我尝试了any,它给出了错误el.pseudoStyle不是函数您在VS代码IDE中或在运行时收到该错误吗?@BasavarajBhusani在运行时