Menu
CoddyTech

The Routed Outlet

Part of the Routing and State section of Coddy's Vue journey. Lesson 2 of 55.

A RouterView is the place where the matched component appears. In this shell, the heading stays on screen while the content inside main changes when navigation selects another record.

<header><h1>City archive</h1></header>
<main><RouterView /></main>

Keep shared controls outside the outlet when they should survive route changes. The router swaps the routed component, not the entire application. A local ref in the shell therefore keeps its value while unrelated routed views mount and unmount.

challenge icon

Challenge

Medium

Place the routed component inside main#outlet with RouterView. Keep the Open studio heading and visit counter outside the outlet. Navigate among all three supplied pages without recreating or resetting the header. The #count button adds one to #visits, starting at zero.

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>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Routing and State