Given the following Vue Router setup, what component will display when the URL path is /about?
import { createRouter, createWebHistory } from 'vue-router'; import Home from './components/Home.vue'; import About from './components/About.vue'; const routes = [ { path: '/', component: Home }, { path: '/about', component: About } ]; const router = createRouter({ history: createWebHistory(), routes }); export default router;
Check which component is linked to the /about path in the routes array.
The route with path /about is linked to the About component, so navigating to /about renders About.
Choose the correct syntax to define a nested route where /dashboard/settings loads the Settings component inside Dashboard.
Nested routes use the children property with relative paths.
Option D correctly uses the children array with a relative path settings to nest the Settings component inside Dashboard.
Consider this Vue Router setup. Why will navigating to /profile/edit cause an error?
const routes = [ { path: '/profile/edit', component: () => import('./EditProfile.vue') }, { path: '/profile/:id', component: () => import('./Profile.vue') } ];
Think about how Vue Router matches routes in order and the importance of route specificity.
Vue Router matches routes in order. Since /profile/:id matches before /profile/edit, the latter is never reached, causing navigation issues.
Given this route definition, what will $route.params.id contain after navigating to /user/42?
const routes = [ { path: '/user/:id', component: UserProfile } ];
Route parameters are always strings in Vue Router.
The :id parameter captures the segment as a string, so $route.params.id is the string "42".
What does the <router-view> component do in a Vue app using Vue Router?
Think about where the content of the current route appears in the app.