0
0
Vueframework~5 mins

Pages and file-based routing in Vue - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is file-based routing in Vue?
File-based routing means the app creates routes automatically based on the files in the pages folder. Each file becomes a page with its own URL.
Click to reveal answer
beginner
How does Vue determine the URL path from a file name in file-based routing?
Vue uses the file name and folder structure to build the URL path. For example, a file named about.vue becomes /about in the URL.
Click to reveal answer
intermediate
How do you create a nested route using file-based routing in Vue?
You create a folder inside the pages folder and put Vue files inside it. The folder name becomes part of the URL path, making nested routes.
Click to reveal answer
intermediate
What special file name is used to create a dynamic route in Vue file-based routing?
You use square brackets around the file name, like [id].vue. This means the route can accept different values for id.
Click to reveal answer
beginner
Why is file-based routing helpful for beginners?
It saves time because you don't write route code manually. You just add files and Vue handles the URLs. It also keeps the project organized.
Click to reveal answer
In Vue file-based routing, what URL does the file pages/contact.vue map to?
A/contact
B/pages/contact
C/contact.vue
D/
How do you create a dynamic route for user profiles in Vue file-based routing?
ACreate a file named <code>user.vue</code>
BCreate a folder named <code>user</code>
CCreate a file named <code>[user].vue</code>
DCreate a file named <code>user-profile.vue</code>
What happens if you create a folder blog inside pages and add post.vue inside it?
AURL becomes <code>/post</code>
BURL becomes <code>/blog/post</code>
CURL becomes <code>/pages/blog/post</code>
DNo route is created
Which file name creates the home page route / in Vue file-based routing?
Aindex.vue
Bmain.vue
Chome.vue
Droot.vue
What is a benefit of using file-based routing in Vue?
AIt disables dynamic routing
BYou must write all routes manually
CIt only works for small projects
DRoutes update automatically when you add or remove files
Explain how Vue uses file names and folders to create routes in file-based routing.
Think about how your folder and file structure looks like a website map.
You got /4 concepts.
    Describe how to create a dynamic user profile page route using Vue file-based routing.
    Dynamic routes use special file names to accept variables.
    You got /3 concepts.