zoukankan      html  css  js  c++  java
  • vue页面params传值的必须传name

    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
        }
    });
    

      

  • 相关阅读:
    HTML
    python io
    python 线程进程
    python socket
    python 面向对象2
    python 面向对象
    python hashlib模块
    python configparser模块
    python logging模块
    数组去重方法汇总
  • 原文地址:https://www.cnblogs.com/matd/p/11573819.html
Copyright © 2011-2022 走看看