router-link
时间: 2023-09-11 10:04:15 浏览: 99
vue router-link传参以及参数的使用实例
5星 · 资源好评率100%
The `router-link` component is a built-in component in Vue Router that allows you to create clickable links that navigate to a specific route in your application. It is used to create links between different pages or views in your application.
The `router-link` component takes a `to` prop, which is used to specify the target route. The `to` prop can be a string or an object, and it can contain dynamic parameters. The `router-link` component renders an anchor tag (`<a>`) with the specified `to` prop as the value of the `href` attribute.
Example usage:
```
<router-link to="/home">Home</router-link>
```
This creates a link to the `/home` route in your application. When the link is clicked, the user will be taken to the corresponding view.
You can also use named routes with the `router-link` component:
```
<router-link :to="{ name: 'about' }">About</router-link>
```
This creates a link to the route with the name `about`. The `name` prop is specified as an object with the key `name` and the value `about`. This is useful when you want to decouple the link from the actual URL, allowing you to change the URL structure without affecting the links in your application.
Overall, the `router-link` component is a powerful tool for creating navigation links in your Vue Router application.
阅读全文