window.onbeforeunload = function (e) { const dialogText = 'cancel?'; e.returnValue = dialogText; return dialogText; };
useEffect(() => { window.onbeforeunload = function (e) { const dialogText = 'cancel?'; e.returnValue = dialogText; return dialogText; }; }, []); react 普通函数方法 用hooks
componentWillMount{ window.onbeforeunload = function (e) { const dialogText = 'cancel?'; e.returnValue = dialogText; return dialogText; }; }
标签:function,浏览器,提示,刷新,onbeforeunload,window,returnValue,dialogText,return From: https://www.cnblogs.com/fyh0912/p/17102157.html