$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