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

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请求,参数不会在地址栏中显示。

 

posted @ 2019-03-12 21:00  奔走的松鼠  阅读(17437)  评论(2编辑  收藏  举报