您的当前位置:首页正文

vue 中query 和params传参

来源:要发发知识网

跳转到home.vue页面:this.$router.push({name:'Home'})

或者this.$router.push({path:'/home'})

 this.$router.push({name:'Home',params:{id:data.id}) 还需要传参的话刷新时会丢失参数相对安全

还需要传参的话 this.$router.push({path:'/home',query:{id:data.id}) 刷新时不会丢失参数,传参信息会出现在地址栏上 ,不安全.

接受query传过来的内容:this.$route.query.xxx

接受params传过来的内容:this.$route.params.xxx