In a Vue 3 app using Vue Router, what does the <RouterView> component render?
Think about how Vue Router shows different pages based on the URL.
The <RouterView> component acts as a placeholder that Vue Router fills with the component matching the current route. It does not render menus or all components, only the one for the active route.
Given this route setup with nested routes, what will the nested <RouterView> render?
const routes = [
{ path: '/parent', component: Parent, children: [
{ path: 'child', component: Child }
]}
]If the URL is /parent/child, what does the nested <RouterView> inside Parent render?
Nested <RouterView> shows the child route's component inside the parent.
When using nested routes, the <RouterView> inside the parent component renders the matched child component. So at /parent/child, the nested <RouterView> renders Child.
Which option correctly uses <RouterView> to render a named view called sidebar?
Vue Router uses a specific prop name for named views.
The name prop on <RouterView> specifies which named view to render. Other props like slot or view are not valid.
In a Vue 3 app, the <RouterView> is empty and shows no content. The routes are defined as:
const routes = [
{ path: '/home', component: Home }
]The URL is /home. What is the most likely reason <RouterView> renders nothing?
Check if the router is connected to the Vue app.
If the router is not installed with app.use(router), the <RouterView> has no route info and renders nothing. The other options are incorrect because the component can be empty but still render, <RouterView> does not require <router-link>, and route paths must start with a slash.
In Vue Router, how can <RouterView> be used to animate page transitions between routes?
Think about how Vue handles animations for dynamic components.
Vue Router does not animate routes by itself. Wrapping <RouterView> in Vue's <Transition> component allows you to animate the entering and leaving of route components. There is no transition prop on <RouterView>, and CSS alone won't handle component lifecycle animations properly. No global router option exists for this.