$router.push
时间: 2023-09-11 16:04:07 浏览: 39
$router.push is a method in Vue.js that allows you to navigate to a different route programmatically. It is used to navigate to another route in the same application without reloading the page.
The $router.push method takes one argument, which is an object that describes the route to navigate to. The object should have a path property that specifies the URL path of the route to navigate to.
For example, if you have a route with the path "/dashboard", you can navigate to it using the following code:
```
this.$router.push({ path: '/dashboard' })
```
You can also pass other properties in the object, such as query parameters or route parameters.
```
this.$router.push({
path: '/product/:id',
params: { id: 123 },
query: { lang: 'en' }
})
```
In this example, we're navigating to a route with a dynamic parameter for the product ID. We're also passing a query parameter to specify the language.
Overall, $router.push is a powerful method that allows you to navigate between routes in Vue.js applications.