Skip to main content

Week 6: Routing, APIs and Mobile Applications

The feed works until someone shares a URL, refreshes a detail page or loses their connection. A successful click-through demo has concealed three application-level failures.

Week06of 12
Vue 229 March 2027
Open lecture deck
URL identifies articleRouter selects pageRequest layer loads data

The question

Can a reader open this article directly, then recover from a failed request?

Why this week exists

Give articles dynamic route parameters and filters query parameters. Compare router-link with named programmatic navigation, optional params and path navigation; query state should survive sharing. Configure redirects, active classes and a not-found route. In Router 3, hash mode is convenient for static hosting; history mode requires a server fallback. Centralise Axios calls and represent pending, error and empty states separately. A route guard changes the experience, but the server remains responsible for authorisation.

Core concepts

Read the boundary

const routes = [
  { path: '/articles/:id', name: 'article',
    component: ArticlePage },
  { path: '/account', component: AccountPage,
    meta: { requiresAuth: true } },
  { path: '*', component: NotFoundPage }
]

This is a focused excerpt, not a complete application. Put it in the context described in the studio and inspect its behaviour.

Build: A routed mobile article browser

  1. Configure Router 3 and build feed, article, account and not-found views. Use the shared fixture contract on the resources page.
  2. Wrap Axios, model a fake login token and protect account routes. Add paginated loading with deduplication by article ID.
  3. Integrate Vant 2 List with a loading flag reset in finally. Start with a 375px design and check 390px and desktop; use flexible widths and rem units rather than fixed pixel scaling.

Try to break it

Paste an article URL into a fresh tab. Try a missing ID, an expired simulated token and a failed next-page request. Retrying must not duplicate articles.

Architecture and migration lens

The request boundary should survive the migration. Components ask for an article; they should not each know where headers and tokens live.

Where this leads

The last missing reader boundary is shared identity. Week 7 puts it in one store.

Open the practical studio · Read the assessment brief

Reading

Official documentation for this week. Read the sections matching the core concepts; bring one example whose behaviour you cannot yet explain.

Lecture slides

People behind the studio

Teaching team