This article describes the vue jump method (open a new page) and parameter transfer operation. Share it for your reference, as follows:
1. router-link jump
// Write the jump address directly<router-link to="/detail/one"> <span class="spanfour" >linkJump</span> </router-link> // Add parameters<router-link :to="{path:'/detail/two', query:{id:1,name:'vue'}}"> </router-link> // Parameter acquisitionid = this.$ // New window opens<router-link :to="{path:'/detail/three', query:{id:1,name:'vue'}}" target="_blank"> </router-link>
2. this.$ jump
toDeail (e) { this.$({path: "/detail", query: {id: e}}) } // Parameter acquisitionid = this.$ toDeail (e) { this.$({name: "/detail", params: {id: e}}) } // Note that the address must be written after the name//Standards are obtained, the difference between params and query, the query parameters are displayed in the address bar, and the params parameters are not displayed in the address barid = this.$
3. this.$ jump
//The difference between push, push has a history record, replace does nottoDeail (e) { this.$({name: '/detail', params: {id: e}}) }
4. Resolve jump
//Resolve page jumps to open new page//After version 2.1.0, use the resolve method of the routing object to parse the route, and you can obtain information about target routes such as location, router, and href. If you get href, you can use it to open a new window (the application here: an answer under /q/101000009557100)toDeail (e) { const new = this.$({name: '/detail', params: {id: e}}) (,'_blank') }
How to receive parametersthis.$
andthis.$
, the following is an example of receiving
Note that when receiving the parameter, it is $route, not $router
<template> <div> testDemo{{this.$}} </div> </template>
Received parameters:
<template> <div>userlist--{{mallCode}} </div> </template> <script> export default { name: "UserList", date:function(){ return {"mallCode":mallCode} }, created(){ () }, methods:{ getParams() { // Get the parameters brought by the route const routerParams = this.$; = routerParams; (this.$); // Put the data in the current component's data // = routerParams; //() } } } </script> <style scoped> </style>
I hope this article will be helpful to everyone's programming.