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

昵称:
随便看看
换一批
-
Spring Boot zalando logbook 过滤不打印指定请求阅读 258
-
Java 中的反射阅读 1483
-
MySQL Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root阅读 5450
-
免责声明阅读 4072
-
HTML 使用 tabindex 控制 Tab 键按键顺序阅读 748
-
不安装 redis-server 下连接 redis阅读 3087
-
单例双重校验为什么还要加 volatile阅读 822
-
PostgreSQL hba 文件的作用阅读 135
-
MongoDB 连接远程数据库阅读 3016
-
MySQL 分页阅读 1550