Routing to Another Route
In a previous section, you linked another route via plan ES6 JavaScript with the <router-link />
component. The <router-link />
component accepts a single prop: to
. The to
prop is equivalent to href
with the <a>
HTML tag. In fact, <router-link />
actually gets rendered as an anchor tag with a href
attribute.
Routing Using String Paths
The easiest way to link to another route is to pass in a string to the to
prop. The string directory corresponds to the path
property in the route
object in the router.js
<router-link
to=
"/about"
>
To the About Page</router-link>
The router-link
above renders out to a <a>
tag:
<a
href=
"/about"
>
To the About Page</a>
Routing Using Names and Parameters
Sometimes it’s easier to remember a name of a route versus the string URL path. You can link to another route by using the name
property in the route object.
router.js
import
Vue
from
'vue&apos...