0
0
Vueframework~20 mins

Pages and file-based routing in Vue - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
File-based Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What does this Vue page component render?
Given a file named src/pages/About.vue in a Vue 3 app using file-based routing, what will the page display when navigating to /about?
Vue
<template>
  <section>
    <h1>About Us</h1>
    <p>Welcome to our site!</p>
  </section>
</template>

<script setup>
// no script needed
</script>
AA blank page with no content
BA page showing 'Home' heading instead
CA page showing a heading 'About Us' and a paragraph 'Welcome to our site!'
DAn error because the script section is empty
Attempts:
2 left
💡 Hint
Think about how Vue file-based routing maps file names to URLs and renders the template.
📝 Syntax
intermediate
1:00remaining
Which file name creates a dynamic route for user profiles?
In Vue file-based routing, which file name inside src/pages correctly creates a dynamic route to match URLs like /user/123 where 123 is a user ID?
Auser/_id.vue
Buser/:id.vue
Cuser/{id}.vue
Duser/[id].vue
Attempts:
2 left
💡 Hint
Vue uses square brackets for dynamic route parameters in file names.
🔧 Debug
advanced
2:00remaining
Why does this nested route not render the child page?
Given these files: - src/pages/dashboard.vue - src/pages/dashboard/settings.vue Navigating to /dashboard/settings shows a blank page. Why?
AThe child file name should be <code>_settings.vue</code> for nested routes
BThe parent <code>dashboard.vue</code> lacks a <code>&lt;router-view&gt;</code> to display child routes
CThe <code>settings.vue</code> file must be inside a folder named <code>dashboard</code> to work
DVue file-based routing does not support nested routes
Attempts:
2 left
💡 Hint
Think about how nested routes display their children in Vue.
state_output
advanced
1:30remaining
What is the value of the route param in this page?
In a Vue page component src/pages/blog/[slug].vue, the script setup contains:
import { useRoute } from 'vue-router';
const route = useRoute();
const slug = route.params.slug;
If the user visits /blog/vue-routing, what is the value of slug?
A"vue-routing"
B"_slug"
Cundefined
D"blog/vue-routing"
Attempts:
2 left
💡 Hint
Route params capture the dynamic part of the URL matching the file name.
🧠 Conceptual
expert
2:30remaining
Which option correctly describes the behavior of catch-all routes in Vue file-based routing?
You want to create a catch-all route that matches any path not matched by other routes, for example to show a 404 page. Which file name inside src/pages achieves this?
A[...all].vue
B_all.vue
C[...all].vue with a <code>definePageMeta({ catchAll: true })</code> in script
Deuv.]lla...[
Attempts:
2 left
💡 Hint
Catch-all routes use a special syntax with three dots inside square brackets.