做网站的资料修改,自己做网站用什么软件,app推广赚佣金,php怎么写购物网站商品显示页面window 的 beforeunload 事件提示在electron 不兼容#xff0c;弹窗提示不出来#xff0c;还会导致莫名其妙的假死问题#xff0c;下面记录一下解决方法。 1. 如果仅需要拦截弹窗#xff1a; win.webContents.on(will-prevent-unload, (event) {event.preventDefault(… window 的 beforeunload 事件提示在electron 不兼容弹窗提示不出来还会导致莫名其妙的假死问题下面记录一下解决方法。 1. 如果仅需要拦截弹窗 win.webContents.on(will-prevent-unload, (event) {event.preventDefault(); // 忽略 beforeunload 事件});
2. 如果需要弹窗提示 win.webContents.on(will-prevent-unload, (event) {const choice dialog.showMessageBoxSync(win, {type: question,buttons: [Leave, Stay],title: Do you want to leave this site?,message: Changes you made may not be saved.,defaultId: 0,cancelId: 1,});if (choice 0) {event.preventDefault(); // 忽略 beforeunload 事件}});
}
以上。