路由传参

时间:2020-04-09 12:14:50   收藏:0   阅读:65
1、params(相当于post)

(1)只能用name,不能用path

(2)参数不显示在路径上

(3)刷新页面参数会被清空

传递参数:

this.$router.push({

?    name:‘details‘,

?    params:{

?        number:123,

?        name:‘product‘

?    }

});

接收参数:

let p=this.$route.params;
2、query(相当于get)

(1)既可以用name,也可以用path

(2)参数显示在路径上,刷新不会被清空

传递参数:

this.$router.push({

    path:‘/details‘,
    
    query:{
    
        number:123,
    
        name:‘product‘
    
    }

});

接收参数:

let q=this.$route.query;

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!