【vue】vue跳转页面传递参数
前言
自己每次用的时候,都是百度,找到合适的要半天,所以就找一篇好点的搬运过来了。
转载自:https://blog.csdn.net/qi_dabin/article/details/82454588
文档2:https://www.jb51.net/article/201173.htm
注意事项
- 跳转是通过tourer,获取参数通过route!!
- 传参:query刷新后不会丢失,但是必须query:{},对应的是一个对象; params传参刷新后会丢失
第一种:push
跳转
this.$router.push({
path: `/describe/${ id}`,
})
路由配置
{
path: '/describe/:id',
name: 'Describe',
component: Describe
}
获取参数
this.$route.params.id
第二种:name
跳转
this.$router.push({
name: 'Describe',
params: {
id: id
}
})
路由
{
path: '/describe',
name: 'Describe',
component: Describe
}
获取参数
this.$route.params.id
第三种:path
跳转
this.$router.push({
path: '/describe',
query: {
id: id
}
})
路由
{
path: '/describe',
name: 'Describe',
component: Describe
}
获取参数
this.$route.query.id
还没有评论,来说两句吧...