Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

十八、vue-router导航钩子有哪些? #18

Open
liwen327 opened this issue Feb 18, 2020 · 0 comments
Open

十八、vue-router导航钩子有哪些? #18

liwen327 opened this issue Feb 18, 2020 · 0 comments

Comments

@liwen327
Copy link
Owner

● beforeEach: 全局前置守卫
● afterEach: 全局后置钩子:
● beforeEnter:路由独享的守卫,与全局前置守卫的方法参数是一样的。
下面这三个是组件内守卫,在单个组件起作用:
● beforeRouteEnter:
beforeRouteEnter (to, from, next) {
// 在渲染该组件的对应路由被 confirm 前调用
// 不!能!获取组件实例 this
// 因为当守卫执行前,组件实例还没被创建
},
● afterRouteUpdate:
beforeRouteUpdate (to, from, next) {
// 在当前路由改变,但是该组件被复用时调用
// 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候,
// 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用。
// 可以访问组件实例 this
},
● beforeRouteLeave:
beforeRouteLeave (to, from, next) {
// 导航离开该组件的对应路由时调用
// 可以访问组件实例 this
}

@liwen327 liwen327 changed the title vue-router导航钩子有哪些? 十八、vue-router导航钩子有哪些? Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant