首页 > 其他 > 详细

vue页面params传值的必须传name

时间:2019-09-23 19:29:40      阅读:181      评论:0      收藏:0      [点我收藏+]
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
    }
});

  

vue页面params传值的必须传name

原文:https://www.cnblogs.com/matd/p/11573819.html

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