$router:this
this.$router.push('/xxx'); 用来切换路由,但本质上是给history栈中添加一个路由(也就是添加一个history记录),该方法能够实现返回上一步。
this.$router.replace('/xxx'); 也是用来切换路由,可是不会生成history记录,所以不能用来返回上一步。
this.$router.go(-1); 实现返回上一步
$route:url
表示当前的路由信息,包含了当前url解析出来的信息。
$route.params this.$route.params.id,通常出如今获取某个详情页面的时候,经过其id获取
$route.query this.$route.query.user,例如,某个路径/xxx?user=xiaowang,那么这里的$this.$route.query.user === xiaowang
$route就列举以上两种,较为经常使用。code
直白来说,一个是用来跳转路由的,一个是存放路由信息的对象。router