码迷,mamicode.com
首页 > 其他好文 > 详细

关于vue-router 中参数传递的那些坑(params,query)

时间:2019-03-12 21:26:48      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:color   页面跳转   的区别   outer   strong   class   路径名   bsp   param   

1.query方式传参和接受参数

1 传参
2 this.$router.push({
3    path:‘/xxx‘
4    query:{
5         idname:id
6       }
7 })
接收的方式:this.$route.query.id

2.params方式传递参数

1 传参:
2 this.$router.push({
3    name:‘路径名称‘
4    query:{
5         idname:id
6       }
7 })
接收的方式:this.$route.params.id

3.query和params的区别,query相当于get请求,在页面跳转的时候,可以在地址栏看到请求参数,然而params则相当于post请求,参数不会在地址栏中显示。

 

关于vue-router 中参数传递的那些坑(params,query)

标签:color   页面跳转   的区别   outer   strong   class   路径名   bsp   param   

原文地址:https://www.cnblogs.com/liweiz/p/10519629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!