vue相关问题

vue路由钩子

2019-04-25  本文已影响2人  一条小团团ovo的就很棒

1.全局钩子
2.某个路由独享钩子
3.组件内钩子

beforeEach(全局前置守卫)、afterEach(全局后置钩子)

Router.beforeEach((to,from,next)=>{
      ......
})
Router.afterEach((to,from,next)=>{
      ......
})
  1. beforeEnter
  2. beforeLeave
{
  path:"/home",
  component:resolve=>require(["../components/home.vue"],resolve),
  beforeEnter:(to,from,next)=>{
      ......
  },
  beforeLeave:(to,from,next)=>{
      ......
  }
}

1.beforeRouteLeave
2.beforeRouteEnter
3.beforeRouteUpdate

  methods:{
      beforeRouteLeave(to,from,next){
            .......
      }
  }
上一篇下一篇

猜你喜欢

热点阅读