Vue前端之路

vue router的钩子函数

2019-08-12  本文已影响140人  小小_绿

1、全局的钩子

beforeEach(to,from,next)
afterEach(to,from,next)

2、组建内的导航钩子

beforeRouteEnter、beforeRouteUpdate、beforeRouteLeave,直接在路由组件内部进行定义的

beforeRouteEnter(to, from, next)
beforeRouteUpdate (to, from, next)
beforeRouteLeave (to, from, next)

3、路由内的导航钩子

const router = new VueRouter({
routes: [
{
path: '/detail',
component: detail,
beforeEnter: (to, from, next) => {
// ...
}
}
]

上一篇 下一篇

猜你喜欢

热点阅读