componentWillUnmount() {
document.removeEventListener('mousedown', (e) => this.handleClick(e), false);
}
componentDidMount() {
document.addEventListener('mousedown', (e) => this.handleClick(e), false);
}
handleClick(e) {
//点在dropdown外面关闭menu菜单
if (!ReactDOM.findDOMNode(this.dropdown.ref).contains(e.target)) {
this.setState({open: false})
}
}
网友评论