0
0
Vueframework~20 mins

RouterLink for navigation in Vue - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
RouterLink Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when you click this RouterLink?

Consider this Vue RouterLink component:

<RouterLink to="/about">About</RouterLink>

What will the user see after clicking this link?

Vue
<RouterLink to="/about">About</RouterLink>
AAn error is shown because 'to' must be an object, not a string.
BNothing happens because RouterLink requires a click handler.
CThe browser navigates to the '/about' route without reloading the page.
DThe browser reloads the entire page and navigates to '/about'.
Attempts:
2 left
💡 Hint

RouterLink is designed to navigate inside the app without full page reload.

📝 Syntax
intermediate
2:00remaining
Which RouterLink syntax correctly navigates to a dynamic user profile with id 42?

You want to create a RouterLink to '/user/42'. Which syntax is correct?

A<RouterLink :to="{ path: '/user/42' }">Profile</RouterLink>
B<RouterLink to="/user/42">Profile</RouterLink>
C<RouterLink to="{ path: '/user/42' }">Profile</RouterLink>
D<RouterLink :to="'/user/' + 42">Profile</RouterLink>
Attempts:
2 left
💡 Hint

Use binding with an object for dynamic routes.

state_output
advanced
2:00remaining
What is the active class applied to this RouterLink when on '/home' route?

Given this RouterLink:

<RouterLink to="/home" active-class="active-link">Home</RouterLink>

If the current route is '/home', what class will the rendered anchor tag have?

Vue
<RouterLink to="/home" active-class="active-link">Home</RouterLink>
AThe anchor tag will have the class 'router-link-active'.
BThe anchor tag will have the class 'active-link'.
CThe anchor tag will have no class applied.
DThe anchor tag will have the class 'active'.
Attempts:
2 left
💡 Hint

Check the active-class prop usage.

🔧 Debug
advanced
2:00remaining
Why does this RouterLink cause a navigation error?

Look at this RouterLink code:

<RouterLink :to="{ name: 'profile', params: { userId: 5 } }">User</RouterLink>

The route named 'profile' expects a param called 'id', not 'userId'. What error will happen?

Vue
<RouterLink :to="{ name: 'profile', params: { userId: 5 } }">User</RouterLink>
ANavigation fails because the required 'id' param is missing.
BNavigation succeeds and goes to '/profile/5'.
CA syntax error occurs due to incorrect param naming.
DThe link renders but clicking it does nothing.
Attempts:
2 left
💡 Hint

Route params must match the route definition exactly.

🧠 Conceptual
expert
2:00remaining
How does RouterLink improve accessibility compared to a plain anchor tag?

Which of the following best explains how Vue's RouterLink component helps with accessibility?

ARouterLink requires manual ARIA labels to be accessible.
BRouterLink disables keyboard navigation to prevent accidental route changes.
CRouterLink replaces anchor tags with buttons which are more accessible.
DRouterLink automatically manages keyboard focus and ARIA attributes for SPA navigation.
Attempts:
2 left
💡 Hint

Think about SPA navigation and keyboard users.