首页 > 其他 > 详细

导航守卫

时间:2019-03-15 14:22:13      阅读:181      评论:0      收藏:0      [点我收藏+]

to  准备跳转到哪个页面

from 从哪个页面中离开

next  函数

全局守卫

router.beforeEach((to,from,next) => {
   if(to.path == ‘/login‘ || to.path == ‘/register‘){
    next(); }else{
    alert(‘先登录‘)
    next(‘/login‘) } })

组件守卫

data () {
  return{
    name: ‘zuo‘
  }
}
beforeRouteEnter:(to, from, next) => {
  next(vm => {
    alert("123" + name)
  })
}
beforeRouteEnter:(to, from, next) => {
  if(confirm("确认离开吗")){
    next();
  }else{
    next(false)
  }
}

 

导航守卫

原文:https://www.cnblogs.com/dreamMargin/p/10536562.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!