1.this.$router.push()
push跳转会向history栈增加一个记录,点击后退会返回到上一个页面。
A -> B ($router.push(“/c”))-> C
在C页面后退,会回到B页面。
2.this.$router.replace()
replace跳转不会向history外面增加新的记录,它是用页面C的地址replace了页面B的地址。在C页面后退,会跳转到B页面的上一个页面。
A -> B ($router.replace(“/c”))-> C
在C页面后退,会回到A页面。
3.this.$router.go(n)
绝对于以后页面向前或向后跳转多少个页面,相似 window.history.go(n)。n可为负数可为正数也能够为0。
this.$router.go(0)刷新以后页面。
this.$router.go(3) // 后退 3 步记录
this.$router.go(n)===window.history.go(n)
注:
<router-link :to="/url">
等同于调用
router.push("/url")
<router-link to="/toPath" target="_blank"> </router-link> 反对新页面关上
同步公布于本人的语雀
https://www.yuque.com/diracke...