First, there are two types of transmission parameters and query params
A way to load directly behind the URL
<! - There are two types of transmission parameters params and Query -> <- params type! -> <- Configure Route format / router /:! Id passed by: the value corresponding to keep back path after transmitting path formed / Router / 123 -> ! <- Get: by $ route.params.id ->
Using v-bind binding data is appended to the routing
<router-link v-bind:to="'/user/'+userId">用户</router-link>
Second way
<! - Second way query configure routing format / router passed by: Key query object used as transfer mode path is formed after the transfer / router id = 123, / - ?>
Add query class behind url
<router-link :to="{path:'/profile',query:{name:'lixiaopei',age:'18',height:'1.75'}}">档案</router-link>
Second way and a way can be achieved through binding events
aboutClick(){ this.$router.push('/about') }, profileClick(){ this.$router.push({ path:'/profile',query:{name:'lixiaoxiaopei',age:'18',height:'1.75'} }) }
Second, the parameter extraction method
The first embodiment by using the current routing params object obtained
computed: { userId () { return $ route.params.userId // the this route is not active when the router route is to take that route. }
· The second way to get through the current query routing object
computed: { userId () { return $ route.query.name // the this route is not active when the router route is to take that route. } }