vue router.push,,router.replace
1.router.push(location)=====window.history.pushState
想要导航到不同的 URL,则使用 router.push
方法。这个方法会向 history 栈添加一个新的记录,所以,当用户点击浏览器后退按钮时,则回到之前的 URL。
1 2 3 4 5 6 7 8 9 10 11 |
|
2.router.replace(location)=====window.history.replaceState
跟 router.push
很像,唯一的不同就是,它不会向 history 添加新记录,而是跟它的方法名一样 —— 替换掉当前的 history 记录
3.router.go(n)====window.history.go
1 2 3 4 5 6 7 8 9 10 11 12 |
|