vue 路由跳转带参 方式query ,params
a.vue向b.vue传值 a.vue this.$router.push({ path: '/payType', query: { putUpList: this.putUpList, name:'111' }, params:{ cartList: this.cartList, totalMoney: this.totalMoney } }); b.vue mounted:function(){ console.log(this.$route.params) console.log(this.$route.query) } 坑来了 query可以拿到,params拿不到 需要在注册路由的地方给路由加上name参数 const router = new VueRouter({ routes:[{ ... },{ path:'/payType', name:'inputComp', component: payType }] }) a.vue跳转路由的地方同样加上name参数,b.vue就可以拿到params了 this.$router.push({ path: '/payType', name: 'inputComp', query: { putUpList: this.putUpList, name:'111' }, params:{//一定要设置name,才可以传params cartList: this.cartList, totalMoney:this.totalMoney } });
本文作者:___mouM
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。
版权说明:本文版权归作者和博客园共有,欢迎转载。但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利.