简体   繁体   English

表单提交出错后如何关闭模态?

[英]how can i close modal after form submitting gives an error?

this is my modal component,这是我的模态组件,

it closes after submit success, but stays on the page if submit fails提交成功后关闭,但如果提交失败则留在页面上

I use the redux form and ant design我使用的是 redux 形式和 ant 设计

Modal.confirm({
  title: title
  content:delete
  okText: yes
  cancelText: no
  okType: 'danger',
  onOk: () => {
      this.props.delete(this.props.id);
  },
});

Try this below:试试这个:

Modal.confirm({
  title: title
  content:delete
  okText: yes
  cancelText: no
  okType: 'danger',
  onOk: () => {
      this.props.delete(this.props.id);
  },
  onCancel() {
  console.log('Cancel'); -------> Your desired Event 
 },
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM