vue全局后置钩子afterEach

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

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

例子:

router.afterEach((to,from)=>{
  if(to.path === "/news"){
    alert("进来news了哦");
  }
})
原文地址:https://www.cnblogs.com/luguankun/p/10699441.html