$router. Push ({name:"name",params:{}"})
{
path: '/home'.name: 'Home'.component: Home
}
this.$router.push({
name:"Home".params: {id:"11111"}})// Get route parameters
this.$route.params.id
Copy the code
This.$router. Push ({path:"path",query:{}"})
{
path: '/home'.name: 'Home'.component: Home
}
this.$router.push({
path:"/home".query: {id:"11111"}})// Get route parameters
this.$route.query.id
Copy the code
Three:
{
path: '/home/:id'.name: 'Home'.component: Home
}
this.$router.push({
path: `/home/${id}`,})// Get route parameters
this.$route.query.id
Copy the code
- In mode 1, parameters are not displayed in the browser address bar. In mode 2 and Mode 3, parameters are displayed in the browser address bar.
- In mode 1, the value disappears after the browser refreshes, while in mode 2 or 3, the value does not.