路由守卫之离开守卫

在做vue项目是遇到一个需求------在业务申请页面,点击右侧任意菜单,页面弹框提示“若该笔业务超过24小时未提交,系统将自动作废!”,点击弹框的“确定”按钮,则离开本页面,否则,留在本页面

代码与methods平级:
beforeRouteLeave(to,from,next){
      if(to.path == '/上一步页面的路由名称'  ||  to.path == '/下一步的路由名称'){
              next()
    }else{
            this.$comconfirm('若该笔业务超过24小时未提交,系统将作废!','温馨提示',function(){
     next()  
   }),function(){
     next(false)
    },'确定','取消')
}

参考链接-----https://blog.csdn.net/caimingxian401/article/details/83107442?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

猜你喜欢

转载自www.cnblogs.com/linm/p/13391830.html