beforeRouteLeave
, 离开当前路由时会先触发该函数,当然也有beforeRouteEnter
,进入路由前先触发该函数。beforeRouteLeave (to, from, next) { this.targetName = to.name // 提示框点击确认后跳转的 路由 if (this.checkEdit()) { // 是否对页面进行了编辑 this.dialogVisible = true // 打开离开页面的提示框 next(false) } else { this.dialogVisible = false next() } }
原文:https://www.cnblogs.com/hexuerui/p/13283370.html