Home  >  Article  >  Web Front-end  >  What is vue’s $router?

What is vue’s $router?

coldplay.xixi
coldplay.xixiOriginal
2020-11-11 10:37:302672browse

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.

What is vue’s $router?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is mix-in in vue.jsNext article:What is mix-in in vue.js