vue-router中query和params传参(接收参数)以及$router、$route的区别


 

query传参:
this.$router.push({
path:'/...'
query:{
id:id
}
})

接收参数:
this.$route.query.id

params传值:

传参:
this.$router.push({
name:'...'
params:{
id:id
}
})

接收参数:
this.$route.params.id

 this.$router 和this.$route的区别

1.$router为VueRouter实例,想要导航到不同URL,则使用$router.push方法

2.$route为当前router跳转对象,里面可以获取name、path、query、params等

 


免责声明!

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



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