在我们构建项目的过程中,会发现router和route,总是分不清楚。
router:在我们进行路由跳转的时候,我们就会用到 router,用的方法就是
this.$router.push({
name:'ddd'
path:'a/b'
query:{
id:1
}
})
route:当我们去取路径的参数值时。我们就用route,用的方式是:
1. 以上跳转的路径取参数id ----------this.$route.query.id(相当于get请求)
2.以router-link的方式跳转的页面, <router-link :to="aa/?name=Anin"></router-link>(相当于get请求)
取值的时候:this.$route.query.name
3.在配置路由的时候配置:path:'a/b/:id'(相当于post请求)
取值的时候:this.$route.params.id