In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the difference between $route and $router in vue. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Routing settings and jump there are two objects $router and $route, is not very similar, a bit silly to distinguish. This article takes you to understand the difference between $route and $router in vue routing. I hope it will be helpful to you!
Recently, I have been learning the value between vue routes, which involves the difference between the two objects $route and $router. I also checked some information on the Internet, and finally made the following summary.
1. $router is an object of VueRouter. An instance object of router is obtained through Vue.use (VueRouter) and Vue constructor. This object is a global object, which contains all routes and contains many key objects and properties.
Take the history object as an example:
$router.push ({path:'home'}), which is essentially adding a route to the history stack, which in our view is switching routes, but essentially adding a history record
$router.replace ({path:'home'}), / / replace route, no history
$router.push ('/ login') to jump to the specified route
2. $route is a jump routing object. Each route will have a $route object, which is a local object, and you can get the corresponding name,path,params,query, etc.
The different structures of the two can see the difference between the two, and some of their properties are different.
The $route.path string, equal to the path of the current routing object, is resolved to an absolute path, such as / home/ews
The $route.params object, which contains the key-value pairs of dynamic fragments and fully matched fragments, will not be spliced after the routed url
The $route.query object that contains the key-value pairs of query parameters in the route. Will be spliced into the back of the routing url
Router to which the $route.router routing rule belongs
$route.matchd array containing the configuration parameter objects of all fragments contained in the currently matched path
The name of the current route of $route.name. If no specific path is used, the name is empty.
After reading the above, do you have any further understanding of the difference between $route and $router in vue? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.