当前位置:   article > 正文

Vue中this.$router.push(参数) 实现页面跳转并接收参数_push跳转页面

push跳转页面
一 ,name跳转页面(命名路由跳转)

命名的路由 params传递的参数相当与发送了一次post请求,请求参数则不会显示,并且刷新页面之后参数会消失

传递参数(貌似是不能传递对象及数组类型):

this.$router.push({ name:'Login', params: { id: this.id } )

接收参数:

this.$route.params.id

二,path跳转页面

对象 query相当与发送了一次get请求,请求参数会显示在浏览器地址栏中

(1)不传递参数单纯跳转

this.$router.push('/task/index')

(2)传递字符串及其他非对象数据

  1. this.$router.push({
  2. path: '/task/index',
  3. query: {
  4. procInsId: record.procInsId,
  5. deployId: record.deployId,
  6. finished: true
  7. }
  8. })

接收参数:

this.$route.query && this.$route.query.deployId

(3)传递对象类型数据

传递当行所有数据record是一个对象{id:'',name:''}

this.$router.push({path: '/task/index',query:{...record}});

接收参数:

this.$route.query 

注:this.$router.currentRoute.query知识点

router.currentRoute 相当于 $route

详情信息:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/285106
推荐阅读
相关标签
  

闽ICP备14008679号