解决vue导航守卫beforeRouteLeave浏览器返回时,页面闪烁
页面闪烁问题,加上延时可解决
beforeRouteLeave(to, from, next) {
if (!this.canReturn) { // 业务判断,无需关注
setTimeout(() => {
this.$confirm('离开内容将被清空, 请确认离开?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
next()
})
.catch(() => {
// 业务代码
})
}, 1)
} else {
next()
}
}