首页 > 其他 > 详细

vue三种页面跳转传参方法

时间:2021-03-29 15:25:54      阅读:125      评论:0      收藏:0      [点我收藏+]

1、push方法:

跳转传参:

 

query传参 参数会在链接后面显示
this.$router.push({ path: "/home", query: { id: 1 }, });

params传参 参数不会显示在链接后面
      this.$router.push({
        name: "/home",
        params: { id: 1 },
      });

params传参要用name 不能用path  切记!

接受参数:

this.$route.params 和 this.$route.query
 
 
 
2、window.href 传参
window.location.href = ‘/home/?id=‘+1;

 

3、router-link标签跳转传参 

 

    <router-link :to="{name:‘home‘,params:{id:1}}">跳转啦</router-link>

 

如果有更好的方法可以一起分享!

vue三种页面跳转传参方法

原文:https://www.cnblogs.com/dells/p/14592225.html

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