Home > Article > Web Front-end > What is vue’s $router?
vue's [$router] is an object of VueRouter. Through [Vue.use(VueRouter)] and the VueRouter constructor, you get an instance object of router. This object is a global object.
The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.
[Related article recommendations: vue.js]
$router
is an object of VueRouter, passed through Vue. The use(VueRouter)
and VueRouter
constructors get a router instance object. This object is a global object, which contains all routes and many key objects and properties.
router is a global routing instance (global variable), which contains all routes, key attributes and methods of routing
Usage:
1, $router.push({path:'/login'})
//Route jump, actually add the path to the history
2, $router.push({path:' /login',query:{name:'userName'}})
//Route pass parameters, get parameters in route
3, $router.replace({path:'/ login'})
//Replace the path in the history directly without recording the jump record; $router.go(-1) cannot return to the page where you clicked to jump
Related Free learning recommendations: JavaScript (video)
The above is the detailed content of What is vue’s $router?. For more information, please follow other related articles on the PHP Chinese website!