[英]How to disable backdrop and close previous open modal in react-modal
Am using react-modal component , 我正在使用react-modal组件 ,
- I don't need backdrop in certain scenarios, how do I disable the backdrop.
在某些情况下我不需要背景,如何禁用背景。 Don't see any property in the documentation.
在文档中看不到任何属性。
- How do I close any previous modal's if opened, whenever a new modal is opened.
每当打开新的模态时,如何关闭以前的模态(如果已打开)。
1) If you don't need backdrop you can always pass the style prop to react-modal: 1)如果不需要背景,可以随时将样式道具传递给react-modal:
style={{overlay:{backgroundColor:"rgba(0,0,0,0)"}}}
Taking a look at the code the default style overlay has a backgroundColor rgba(255, 255, 255, 0.75). 看一下代码,默认样式叠加层具有backgroundColor rgba(255,255,255,0.75)。
2) If you want to close other modals when a new one is opened you can just change the value of the isOpen prop: 2)如果要在打开新模态时关闭其他模态,则只需更改isOpen属性的值即可:
isOpen={this.state.showModalOne}
When you open the ModalTwo you will call: 当您打开ModalTwo时,您将调用:
this.setState({showModalOne:false, showModalTwo:true});
If modals are in different components you can work with props. 如果模态位于不同的组件中,则可以使用道具。 You can even choose to not close the modal but change only its content.
您甚至可以选择不关闭模式,而仅更改其内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.