1. router-link
1. With no arguments < the router - link: to = "{name: 'home'}" > < the router - link: to = "{path: '/ home'}" > / / name, path, suggest using name / / note: In router-link, if a link starts with a '/', it starts from the root route; if a link does not start with a '/', it starts from the current route. <router-link :to="{name:'home', params: {id:1}}"> // Params upload parameters (similar to post) // Route configuration path: "/home/:id" or path: "/home:id" // no path is configured, the first request can be made, the page ID will not be refreshed // Set path, the page ID will be retained // HTML take the parameter $route.params.id // script take the parameter this.$route.params.id <router-link :to="{name:'home', query: {id:1}}"> // query: $route.query.id; // HTML: $route.query.idCopy the code
  1. This.$router.push() (called in function)
Push ('/home') this.$router.push({name:'home'}) this.$router.push({path:'/home'}) this this.$router.push({name:'home',query: {id:'1'}}) this.$router.push({path:'/home',query: {id:'1'}}) // HTML fetch parameter $route.query.id // script fetch parameter this.$route.query.id 3 This.$router.push({name:'home',params: {id:'1'}}) "/home:id" , $route. Params. id = $route. Params. id = $route. The difference between query and params is that query is like get, and after a jump, the page URL will be concatenated, like that, right? If id=1, non-important pages can be passed in this way, such as password, params will still refresh the page ID, params is similar to POST, after the jump to the page URL does not concatenate parameters, but the refresh page ID will disappearCopy the code
  1. This.$router. Replace () (same as above,push)
  2. this.$router.go(n) ()
 this.$router.go(n) ()
Copy the code

Jump forward or backward n pages. N can be a positive or negative integer

The difference between

$router. Replace // This.$router. Replace // This.$router. $router. Go (n); // This.$router. Go (n)Copy the code