Performance: Pages and file-based routing
This affects the initial page load speed and navigation responsiveness by controlling how routes are resolved and components are loaded.
const routes = [ { path: '/', component: () => import('./pages/Home.vue') }, { path: '/about', component: () => import('./pages/About.vue') } ];
import Home from './pages/Home.vue'; import About from './pages/About.vue'; const routes = [ { path: '/', component: Home }, { path: '/about', component: About } ];
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager import of all pages | Low (few nodes initially) | 1 reflow on load | High paint cost due to large bundle | [X] Bad |
| Lazy load pages with file-based routing | Low (few nodes initially) | 1 reflow on load | Lower paint cost due to smaller bundle | [OK] Good |
about.vue inside the pages folder represent?pages folder automatically become routes matching their file names.about.vue creates a route at /about directly.userId in Vue file-based routing?[userId].vue inside the folder representing the route.pages:pages/
blog/
[slug].vue
index.vueblog/[slug].vue when visiting /blog/vue-routing?[slug].vue inside blog folder captures the segment after /blog/ as slug./blog/vue-routing sets slug to 'vue-routing' for the component.pages/blog/[postId].vue but visiting /blog/123 shows a 404 error. What is the most likely cause?pages folder must exist at the correct location.pages folder is missing or misnamed, routes won't be generated, causing 404 errors./blog/tech/vue-routing. Which folder and file structure inside pages correctly sets this up?/blog/tech/vue-routing has two dynamic parts after /blog: category and post.pages/blog/[category]/[post].vue matches the URL segments correctly.Pass the test and this pattern moves unknown