Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal.alert弹出后,怎么在销毁事件时关闭弹窗 #995

Closed
liuxingling opened this issue Mar 15, 2017 · 5 comments · Fixed by #998
Closed

Modal.alert弹出后,怎么在销毁事件时关闭弹窗 #995

liuxingling opened this issue Mar 15, 2017 · 5 comments · Fixed by #998
Assignees

Comments

@liuxingling
Copy link

Modal.alert弹出后,如果不点击‘确定’,或者‘关闭’,浏览器前进或后退,弹窗会一直存在,想在销毁的时候手动关闭弹窗。

@paranoidjk
Copy link
Contributor

paranoidjk commented Mar 15, 2017

给Modal加个ref,在你的页面componentWillUnmount的时候调一下this.refs.xxx.close()

我添加一个api

@liuxingling
Copy link
Author

@paranoidjk 我用的Modal.alert,这个ref加到哪里啊。
<Button
data-role="btnOrg" onClick={() => alert('提示', tip, [
{ text: '取消' },
{ text: '确定', onPress: () => callback(), style: { fontWeight: 'bold' } },
])}
>删除

@paranoidjk
Copy link
Contributor

@liuxingling 见我上面的回复,暂时加不了,我会添加一个API #998

类似这样

const alertInstance = Modal.alert();
alertInstance.close(); // 手动关闭

@liuxingling
Copy link
Author

@paranoidjk 能临时解决我的问题不?

@paranoidjk
Copy link
Contributor

@liuxingling 本周五,也就是明天会发新版本。

实在等不及的话你可以参照这个 https://github.com/ant-design/ant-design-mobile/blob/master/components/modal/alert.web.tsx#L23 自己销毁dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants