目前测试俩种方法均可
传参方式1:
1)父组件通过name来匹配
this.$router.push({
name: 'Describe',
params: {
id: id
}
})
2)相应路由配置:
{
path: '/describe/:id',
name: 'Describe',
component: Describe
}
3)子组件是通过:
this.$route.params.id
传参方式2:
父组件:this.$router.push({
path: '/describe',
query: {
id: id
}
})
路由设置:
{
path: '/describe',
name: 'Describe',
component: Describe
}
子组件获取:
this. $route.query.id
网友评论