vue-router路由

查询参数

查询参数其实就是在路由地址后面带上参数和传统的url参数一致的,传递参数使用query而且必须配合path来传递参数而不能用name,目标页面接收传递的参数使用query。
注意:和name配对的是params,和path配对的是query

使用方法:

this.$router.push({ path: '/news', query: { userId: 123 }});
路由路径可以用 this.$route.path
路由路径参数 this.$route.params 例如:/user/:id → /user/2044011030this.$route.params.id
路由查询参数 this.$route.query 例如:/user/search?name=sf → this.$route.query.name

来源:https://blog.csdn.net/crazywoniu/article/details/80942642

原文地址:https://www.cnblogs.com/zhizou/p/11314586.html