Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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 chrome和IE中的ScrollHeight值不同_Javascript_Reactjs - Fatal编程技术网

Javascript chrome和IE中的ScrollHeight值不同

Javascript chrome和IE中的ScrollHeight值不同,javascript,reactjs,Javascript,Reactjs,如果元素溢出,我想对div应用一个类。为此,我将ScrollHeight与ClientHeight进行了比较。它在chrome上运行良好,但在IE中不起作用。下面是代码片段: componentDidMount() { this.assign_overflow(); } assign_overflow = () => { const element = this.title_ref.current; element.classList.toggle('overflo

如果元素溢出,我想对div应用一个类。为此,我将ScrollHeight与ClientHeight进行了比较。它在chrome上运行良好,但在IE中不起作用。下面是代码片段:

componentDidMount() {
   this.assign_overflow();
}

assign_overflow = () => {
    const element = this.title_ref.current;
    element.classList.toggle('overflowing', element.scrollHeight > 
    element.clientHeight);
};

<div>
    <h5 ref={this.title_ref}>header</h5>
</div>

.overflowing::after {
    content: "...";
    position: absolute;
    bottom: -2px;
    background-color: yellow;
}
componentDidMount(){
这是。分配_溢出();
}
分配溢出=()=>{
常量元素=this.title\u ref.current;
element.classList.toggle('overflow',element.scrollHeight>
元素(重量);
};
标题
.溢出后{
内容:“…”;
位置:绝对位置;
底部:-2px;
背景颜色:黄色;
}

在IE中,我看到类“溢出”应用于元素,即使它不应该是。在chrome中,我得到的scrollheight值是20,在IE中是22。有人能帮我吗。谢谢。

您正在运行哪个版本的IE?请尝试将此:
元标记添加到您的
。Internet explorer版本11