我在 React 中有一个模态。当您单击模态框的背景时,模态框应该关闭。我现在设置它的方式,如果你点击里面*模式,它也会关闭。因为模态在背景里面>
handleClose(e) {
e.stopPropagation();
this.props.history.push('/business/dashboard')
}
render() {
return (
<Background onClick={e => this.handleClose(e)} name="BACKGROUND">
<Container onClick={console.log("IT CLICKED")} to={'/business/dashboard'} name="CONTAINER">
....
当我单击 Container 时,会调用 Background 的 onClick 事件。我不希望这种情况发生。这是用户将一直点击的表单。我只需要在您单击背景上的模态外部时关闭模态。