弹出窗口上的“关闭”按钮在Internet Explorer上不起作用

时间:2019-05-30 00:41:05

标签: javascript reactjs

我有一个弹出窗口,单击按钮即可打开,但是当我关闭弹出窗口时,它不会在IE上关闭,但可以在其他浏览器上使用。当我尝试关闭IE上的弹出窗口时出现小故障

    toggleExpand(e) {
        e.preventDefault()
        e.stopPropagation();
        if (!this.state.expanded) {
            document.addEventListener('click', this.handleOutsideClick, false);
        } else {
            document.removeEventListener('click', this.handleOutsideClick, false);
        }

        this.setState({
            expanded: !this.state.expanded
        });
    }

    handleOutsideClick(e) {
        if (this.node.contains(e.target)) {
            return;
        }

        this.toggleExpand(e);
    }

    toggleOpen(e) {   
        e.preventDefault()
        e.stopPropagation();
    }

//渲染div

render() {
  return (
                    {this.state.expanded && (
                            <div
                                className={styles.pointer}
                            >
                                <div
                                    onClick={this.toggleOpen}

                                >
                                    <button
                                        onClick={this.toggleExpand}
                                        className={[
                                            styles.close}
                                        alt="Close Button"

                                    />

                                    <div
                                        className={
                                            styles.pop}
                                     >
                                        <div>
                                            <span className={styles.label}>
                                            abcd 
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        )}

)}

0 个答案:

没有答案