Vue Router is the official route manager of vue.js. Its deep integration with vue.js core makes building single-page applications a breeze. The features included are:

  • Nested routing/view chart
  • Modular, component-based routing configuration
  • Route parameters, queries, and wildcards
  • View transition effect based on vue. js transition system
  • Fine-grained navigation control
  • Links with automatically activated CSS classes
  • HTML5 historical mode or Hash mode is automatically degraded in IE9
  • Custom scroll bar behavior

There are six hook functions for routing

Global routing hook functions: beforeEach, afterEach

Single routing hook function: beforeEnter

Component routing hook functions: beforeRouteEnter, beforeRouteLeave, beforeRouteUpdate

 

Module 1: Global navigation hook functions

1. Vue router. BeforeEach (Global front-guard)

BeforeEach hook function, which is a global before hook function,

BeforeEach means that each route change must be executed every time.

Its three parameters:

To: (Route Route object) Target Route object to be entered. The following attributes of the to object are: Path Params Query