1 Vue router如何传参
params、query是什么?
params:/router1/:id ,/router1/123,/router1/789 ,这里的id叫做params
query:/router1?id=123 ,/router1?id=456 ,这里的id叫做query。
2 注意 $ route和$router的区别:
需要注意的是:传参是this. $ router ,而接收参数是this.$route,千万要小心哟!!!
$route是“路由信息对象”,包括path,params,hash,query,fullPath,matched,name等路由信息参数。
而$router是“路由实例”对象包括了路由的跳转方法,钩子函数等。
3关于路由传参的区别:
1:query方式传参和接收参数:
传参:
this.$router.push({
path:'/xxx'
query:{
id:id
}