vue三种页面跳转传参方法


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>

 

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM