confirmLeave(callback) {
let isCondition = true; // 是否存在数据
if (isCondition ) {
MessageBox.confirm("您当前页面数据还没保存,确认要离开吗?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
type: "warning",
center: true
})
.then(_ => {
callback()
})
.catch(err => {
});
} else {
callback()
}
},
// 调用
beforeRouteLeave(to, form, next) {
this.confirmLeave(function(){
next()
});
},