离开页面前的提示
data() {
},
beforeRouteLeave(to, from, next) {
//mintui 弹窗组件
this.$Messagebox
.confirm("", {
message: "Do you really want to leave? you have unsaved changes!",
title: "提示",
confirmButtonText: "确定",
cancelButtonText: "稍后再说"
})
.then(action => {
if (action == "confirm") {
next();
}
})
.catch(err => {
if (err == "cancel") {
next(false);
}
});
},
进入页面前的提示
beforeRouteEnter(to, from , next) {
//window自带弹窗
const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
if (answer) {
next()
} else {
next(false)
}
}