方法1-传值
<router-link to="/home?id=11">Go to Bar</router-link>
**取值方式** this.$route.query.id
方法2-传值
<router-link to="/home/参数1/参数2">Go to Bar</router-link>
routes: [
{
path: ‘/home/:id/:name’, 参数名1:id 参数名2:name
name: ‘hello’,
component: hello
}
]
获取值 this.$route.parmas.id
方法3-传值
<a @click=“routerTo”>Go to Bar
methods:{
routerTo(){
this.$router.push({ name: ‘hello’, params: { userId: 123 }});
}
}
获取值 this.$route.params.userId