首页 > 其他 > 详细

this.$router.push 传参

时间:2020-03-06 16:10:29      阅读:63      评论:0      收藏:0      [点我收藏+]

index页面
1.params
this.$router.push()方法中path不能与params同用,否则param会失效,所以用name来指定页面,params来传递数据内容。

 1 <template>
 2 <img src="../../static/images/indexTermianal/teacher.png" alt="" @click ="go()" > 
 3 </template>
 4 <script>
 5 methods:{
 6   go:function(){
 7     this.$router.push({
 8       name:indext,
 9       params:{
10         userId:1
11       }
12     })
13   }
14 }
15 </script>

 

在目标页面通过this.$route.params获取参数:
<p>{{this.$route.params.userId}}</p>

2.query
页面通过path和query传递参数,该实例中row为某行表格数据

 1 methods:{
 2     go:function(){
 3         this.$router.push({
 4         path:/indext,
 5       query:{
 6         userId:1
 7       }
 8      })
 9   }
10 },        

 



目标页面this.$route.query.userId获取数据

<p>{{this.$route.query.userId}}</p>

this.$router.push 传参

原文:https://www.cnblogs.com/gwkzb/p/12426364.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!