The difference between Vue--router and route

1. Router

router is an instance object obtained through the VueRouter constructor new. This object is a global routing object, which contains all routing objects and attributes

Similar to the history object

The more commonly used attributes are:

currentRoute: the routing object of the current page

options.routes: all routing objects

The more common method is

$router.push('url') : Jump to the specified route

$router.back() : Jump to the previous route

$router.go(n) : When n is 1, it means jump to the next level of routing, when -1 means the upper level of routing

2. Route

route is a page jump routing object, each page has a route object, which is a local routing object

Common attributes are:

$route.path : the path of the current routing object, such as ' /login '

$route.params : dynamic matching parameters of the route

$route.query : The key-value pair of query parameters of the route, such as /login?username=hsq, then $route.query.username==' hsq '

$route.name : the name of the current route, which is the name attribute of the route

Guess you like

Origin blog.csdn.net/h18377528386/article/details/127796523