基本传值:
传:
this.$router.push('/path地址?参数名=参数值&参数2=值2')
this.$router.push({
path:'/path地址',
query:{
参数名:值
、。。。
}
})
收
this.$route.query.参数名
动态路由匹配:
配制路由
{
path:'/xxx/:参数名?' ?代表参数值可传可不传
}
传:
this.$router.push('/xxx/值')
收:
this.$route.params.参数名===值
name传参
配制路由
{
path,
component,
name:'abc'
}
传:
this.$router.push({
name:'abc',
query:{
参数名:参数值
}
})
this.$router.push({
name:'abc',
params:{
参数名:参数值
}
})
这种传值方式它不会在url体现,它的值存储在内存中,刷新就没了,优点:不受长度与数据类型影响(类似post传值)
接:this.$route.query.参数名
this.$route.params.参数名
路由的传值
最新推荐文章于 2023-08-09 22:14:57 发布