问题:
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那样的弹框。

本文介绍了如何在Ant Design中自定义Confirm组件的行为以实现点击外部链接后自动关闭弹窗的功能。通过使用Modal.info提供的销毁方法,可以在点击事件后立即关闭确认框。

4046

被折叠的 条评论
为什么被折叠?



