路由传参

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;

猜你喜欢

转载自www.cnblogs.com/annie211/p/12665963.html