当我在页面中按刷新时,我想要显示此模式:

但我想防止页面重新加载,除非我单击了continue按钮。
这是代码
import dialog from '@catapulthealth/catapult-dialog';
.
.
.
componentDidMount() {
window.addEventListener('beforeunload', this.showModal);
}
showModal() {
return (
dialog({
title: 'We are processing your file',
body: 'Importing will continue even if you leave the page',
buttons: {
ok: 'Continue',
},
})
);
}对话框,它来自一个私有库。如何停止重新加载页面?
发布于 2018-09-21 05:57:34
点击Button后,你就可以使用Cookie,所以当页面重新加载时,你必须检查cookie是否设置好了。在cookie的基础上,你可以显示隐藏弹出窗口。请查看以下代码参考。
import cookie from "react-cookie";
setCookie() => {
let d = new Date();
d.setTime(d.getTime() + (minutes*60*1000));
cookie.set("onboarded", true, {path: "/", expires: d});
};https://stackoverflow.com/questions/52433790
复制相似问题