1. Two common ways to route
1) Declarative form:
<router-link to="/login"> <router-link :to="{ path: '/login' }">Home</router-link> <router-link :to="{ name: 'loginPage'}">User</router-link>
2) Programming:$(...)
The parameters of the method can be a string path, or an object describing the address.
// If the existing route is (login in) import LoginPage from "@/views/"; const router = new VueRouter({ [{ path: "/login", name: "loginPage", component: LoginPage }] }); // String (corresponding to the path above) this.$('/login') // Object this.$({path: '/login'}); // The name of the route (corresponding to the name above) this.$({ name: 'loginPage' })
2. Pass parameters and get parameters (query and params)
1) query method
this.$({<!--{C}%3C!%2D%2D%20%2D%2D%3E-->path:"/login",query:{<!--{C}%3C!%2D%2D%20%2D%2D%3E-->message:"Page jump successfully"}})
New page/routing Get parameters
(this.$);
2) Params method
this.$({<!--{C}%3C!%2D%2D%20%2D%2D%3E-->name:"loginPage",params:{<!--{C}%3C!%2D%2D%20%2D%2D%3E-->message:"Page jump successfully"}})
New page/routing Get parameters
(this.$);
Notice:
this.$()
In the methodpath
Can't be withparams
Use together, otherwiseparams
Will be invalid. Need to usename
To specify the page and configure it through routingname
Attribute access
The difference between the two methods is:
- The parameters of the query parameter will be displayed in the address bar after the url.
- Params passed parameters will not be displayed in the address bar (the parameters are invalid after refresh).
Summarize
This is the article about $() routing switching in Vue and how to transfer parameters and obtain parameters. For more related Vue $() routing switching content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!