Home> Web Front-end> Vue.js> body text

What is vue's $router?

coldplay.xixi
Release: 2020-11-30 14:00:36
Original
2597 people have browsed it

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]

$routeris an object of VueRouter, passed throughVue. The use(VueRouter)andVueRouterconstructors 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!

Related labels:
source:php.cn
Statement of this Website
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