Vue Router 页面间传递参数
Vuevue-router大约 557 字params
跳转到posts
页面,携带postId
参数。
this.$router.push({
name: 'posts',
params: {
postId: 123
}
})
posts
页面,接收postId
参数。
<div>
params from other: {{this.$route.params.postId}}
</div>
页面路径
http://localhost/posts
query
跳转到posts
页面,携带postId
参数。
this.$router.push({
path: 'posts',
query: {
postId: 123
}
})
posts
页面,接收postId
参数。
<div>
query from other: {{this.$route.query.postId}}
</div>
页面路径
http://localhost/posts?postId=123
区别
使用params
方式传递参数,页面刷新后将获取不到参数的值。而使用query
方式传递参数则不受刷新影响,一直可以获取参数的值。
阅读 101 · 发布于 2020-11-30
————        END        ————
扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看换一批
- MySQL存储Emoji表情阅读 374
- 软考-系统架构设计师:数据备份阅读 363
- 使用MyBatis注解接收PostgreSQL的returning结果阅读 631
- Spring Boot使用Session管理登录状态和拦截请求阅读 1425
- Linux常用命令之基础命令阅读 469
- Redis线上禁用命令阅读 460
- AndroidStudio设置so库过滤阅读 1403
- IDEA去除Unchecked cast from Object to提示阅读 821
- AndroidStudio non-zero value 1 错误阅读 374
- OpenResty使用ngx.timer.every完成定时任务阅读 1353