首页 > 技术文章 > vue全局后置钩子afterEach

luguankun 2019-04-13 00:09 原文

beforeEach是路由跳转前执行的,afterEach是路由跳转后执行的。

afterEach只有两个参数  afterEach((to,from)=>{})

例子:

router.afterEach((to,from)=>{
  if(to.path === "/news"){
    alert("进来news了哦");
  }
})

 

推荐阅读