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
MediumWire #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>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