版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39517820/article/details/83446877
正常 js 页面处理方式
window.onbeforeunload = function (e) {
e = e || window.event;
// 兼容IE8和Firefox 4之前的版本
if (e) {
e.returnValue = '关闭提示';
}
// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
return '关闭提示';
};
vue 中处理方式
let _this = this
window.onbeforeunload = function (e) {
if (_this.$route.name == "dyyPerformanceCenterSale") {
e = e || window.event;
// 兼容IE8和Firefox 4之前的版本
if (e) {
e.returnValue = '关闭提示1111';
}
// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
return '关闭提示222';
} else {
window.onbeforeunload = null
}
};