Antd Modal,单击“蒙版”不执行任何操作

因此,默认情况下,当用户单击蒙版(模态之外的区域)时,Antd Modal将触发Modal的onCancel属性。

但是我想要的是该程序在用户单击蒙版时不触发任何东西(只需关闭模态而不更改任何内容),因为我在onCancel中具有自己的功能。我该怎么做?提前致谢!


www说
浏览 765回答 3
3回答

慕容森

如此简单,您可以在模态:D上删除onCancel行&nbsp; &nbsp; &nbsp; <Modal&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title="Basic Modal"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; visible={this.state.visible}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onOk={this.handleOk}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //onCancel={this.handleCancel}&nbsp; &nbsp; &nbsp; &nbsp; >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p>Some contents...</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p>Some contents...</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p>Some contents...</p>&nbsp; &nbsp; &nbsp; &nbsp;</Modal>

心有法竹

一种选择是保持对可用按钮的控制(cancel和ok),并在使用maskClosable = {false}单击蒙版时阻止任何操作。<Modal&nbsp; &nbsp; &nbsp; title="Basic Modal"&nbsp; &nbsp; &nbsp; visible={this.state.visible}&nbsp; &nbsp; &nbsp; onOk={this.handleOk}&nbsp; &nbsp; &nbsp; onCancel={this.handleCancel}&nbsp; &nbsp; &nbsp; maskClosable={false}&nbsp; &nbsp; >&nbsp; &nbsp; &nbsp; <p>Some contents...</p>&nbsp; &nbsp; &nbsp; <p>Some contents...</p>&nbsp; &nbsp; &nbsp; <p>Some contents...</p></Modal>现在,在模式窗口外单击将不会触发任何操作。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript