Vue Router 页面间传递参数
Vue 大约 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
方式传递参数则不受刷新影响,一直可以获取参数的值。
阅读 761 · 发布于 2020-11-30
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
JavaScript 打开页面三种方式阅读 1870
-
MySQL 查看版本号阅读 1610
-
Git 提示 You asked me to pull without telling me which branch you...阅读 3800
-
MySQL ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'阅读 3970
-
PostgreSQL 统计数组中的元素个数阅读 4179
-
Redis 实现统计在线人数、每日签到功能阅读 4163
-
Linux 之 CentOS 安装 JDK 及 JRE阅读 1963
-
Java jar 包启动时指定 JVM 时区阅读 3810
-
JavaScript WebSocket 为什么不提供 ping 和 pong阅读 846
-
Java 并发编程之 AQS ReentrantLock 公平锁源码解析阅读 514