router.replace
时间: 2023-10-24 18:18:53 浏览: 48
router.replace() is a method in the Vue Router that allows you to navigate to a new route without adding a new entry in the browser's history stack. This means that when the user clicks the back button, they won't go back to the previous page they were on before the route change.
The syntax for using router.replace() is as follows:
```
router.replace(location, onComplete?, onAbort?)
```
- location: A string or object that represents the URL you want to navigate to.
- onComplete: A callback function that is called when the navigation is complete.
- onAbort: A callback function that is called when the navigation is aborted.
Here's an example of using router.replace() to navigate to a new route:
```
this.$router.replace('/new-route')
```
This will take the user to the "/new-route" URL without adding a new entry to the browser's history stack.