Vue 3·Practice drills 12

Drill 29: Beginner mistake — Routing

Name one mistake a beginner could make with this example.

Intermediate 5 min read Lesson 299 of 300 Challenge included
What you will be able to do
  • Name one mistake a beginner could make with this example.

Practice task

Name one mistake a beginner could make with this example.

router.jsJavaScript
import { createRouter, createWebHistory } from 'vue-router'
import Lessons from './Lessons.vue'
import Lesson from './Lesson.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    { path: '/lessons', component: Lessons },
    { path: '/lessons/:slug', component: Lesson, props: true },
  ],
})

router.beforeEach((to) => {
  if (to.meta.private && !localStorage.getItem('token')) return '/login'
})

export default router
Your turn

Write your answer

Easy

Name one mistake a beginner could make with this example.

TEXT · starter
Your answer…
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 299 of 300 · 0% of course