Vue routing guard summary

Vue routing guard

There are three types of routing guards, global guards, exclusive guards, and component guards

Global guard

  • Global front guard (beforeEach(to,from,next))
    description: After configuring the global front guard, all routes entering the door will start the global front guard, which is often used to judge whether to log in and to judge whether the logged-in account has permission to enter This page. Generally this guard uses more
  • Global resolution guard (beforeResolve(to,from,next))
  • Global rear guard (afterEach(to,from))

Exclusive guard

  • beforeEnter(to,from,next): This guard needs to be configured separately in each route

Component guard

  • beforeRouteEnter
  • beforeRouteUpdate
  • BeforeRouteLeave
    description: When routing parameters change and query, the two guards beforeRouteEnter and beforeRouteLeave will not be triggered. The
    this pointer cannot be directly accessed in beforeRouteEnter, but it can be called by passing in the vm instance in next.

Guess you like

Origin blog.csdn.net/Chennfengg222/article/details/106196087