使用antd confirm 定义弹框关闭事件

版权声明:如需转载,请注明出处 https://blog.csdn.net/zr15829039341/article/details/82772464

问题:

1、confirm 使用

在使用antd的confirm确认时,需要在点击事件发生后关闭弹框。但是confirm提供的关闭只有 确定 按钮。那么就需要自定义关闭弹窗。

点击  密码修改页  之后 会打开新的tab页,所以需要弹框在点击之后也关闭。

解决:

confirm提供了一个弹窗的销毁方法

const info = Modal.info({})

info.destroy();

具体代码:

const Info = Modal.info({
      title: '重置密码',
      content: 
          <div>
             <span>修改密码请至</span>
             <span 
                    onClick:()=>{
                         window.open('http://xx/passport/','_blank');
                         Info.destroy();
                    }
             >密码修改页</span>
          </div>
});

ps: 为什么不直接使用modal,定义this.setState({visible:false})来控制弹框关闭。

好问题,

因为太懒了,这个页面没有使用state,如果因为弹框关闭要使用,还得写初始化,显示,关闭等。 

而且确实只是一个通知,不需要modal那样的弹框。

猜你喜欢

转载自blog.csdn.net/zr15829039341/article/details/82772464