1:通过路由配置
this.$router.push({
path:`/describe/${'222'}`
})
路由配置:
{
path:'/describe/:id',
name:'Describe',
component: Describe
}
2:不跟在url后面 params传参
this.$router.push({
name:'Describe',
params: {
id:"hhhh"
}
})
路由:
{
path:'/describe',
name:'Describe',
component: Describe
}
子组件获取方式::this.$route.params.id
3:跟在url后面 query传参
this.$router.push({
path:'/describe',
query: {
id:"ahaha"
}
})
路由配置
{
path:'/describe',
name:'Describe',
component: Describe
}
子组件获取方式::this.$route.query.id
网友评论