Router Links
Part of the Routing and State section of Coddy's Vue journey. Lesson 3 of 55.
Use RouterLink for navigation managed by Vue Router. This link renders an anchor whose destination is /maps; clicking it asks the router to select that location without a full-page reload.
<RouterLink to="/maps">View maps</RouterLink>
<RouterView />A string to is a path. A bound :to can read a reactive value, so a changing destination also updates the rendered href. A plain anchor is useful for external documents, but it does not provide the same client-router navigation behavior.
Challenge
MediumComplete the three navigation controls using RouterLink: #home targets /, #events targets /events, and #help targets /help. Each control must render an anchor with the matching href. Preserve the supplied shell note while switching routes.
Keep the supplied route readout and bootstrap files.
Try it yourself
<!doctype html><html><head><meta charset="UTF-8"><title>Routing practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Routing and State
4Query State
Reading Query ValuesCommitting Search QueriesPreserving Other FiltersNormalizing Query NumbersRecap: Catalog Filters2Navigation Actions
Navigation from HandlersReplacing HistoryHistory TravelCurrent Navigation LinksRecap: Save and Review5Nested Layouts
Parent and Child OutletsDefault Child ViewsRelative Child PathsAncestor Navigation StateRecap: Library Workspace8Store Design
Setup Store StructurePatching Related StateResetting Store StateComposing Related StoresRecap: Trip Pack11Workshop Planner Project
Planner RoutesShared Reservations