[英]react-responsive-modal : how to prevent closing of modal when we click outside the div
[英]How to prevent click outside React Modal?
将此行添加到模态组件
<ReactModal
//other props declaration..
shouldCloseOnOverlayClick={false} // add this to prevent outside click to prevent modal close
>
或使用event.preventDefault()
进行修复
1.当模式打开时,向父元素添加一个类,
.inactive {
pointer-events: none; // pointer-events not supported below IE11
position: fixed;
}
如果您已将整个页面包装在模式包装器中,则将此类添加到包装器中
将shouldCloseOnOverlayClick
道具用于<ReactModal />
进行外部点击。 当模式打开时,它添加.ReactModal__Body--open
到主体。 (它可以重命名。)您可以添加overflow-y: auto;
到 css 中的 class 进行外部滚动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.