Menu
CoddyTech

History Travel

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

The router can travel through existing history entries. After visiting /rooms and then /prices, router.back() returns to rooms, while router.forward() can revisit prices.

await router.push('/rooms');
await router.push('/prices');
router.back();
// After navigation completes, the route is /rooms.

Use router.go(-2) to move two entries backward, or a positive number to move forward. These operations depend on the history that actually exists. Replacing Back with a push to a fixed page creates another entry and cannot correctly revisit different previous pages.

challenge icon

Challenge

Medium

Wire #back and #forward to the router history methods. Navigate through the supplied details and complete links, then travel backward and forward through those existing entries. The controls must use navigation history rather than a fixed destination.

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