Basic routes are created by simply adding .vue files with fixed filenames to the /pages/ directory. You can also create sub-routes by organizing .vue files into different folders. Take the following example:
pages/
--| users/
-----| index.vue
-----| john-doe.vue
--| index.vue
Then, Nuxt will generate the following routes for you without you having to write any of them:
router: {
routes: [
{
name: 'index',
path: '/',
component: 'pages/index.vue'
},
{
name: 'users',
path: '/users',
component: 'pages/users/index.vue'
},
{
name: 'users-john-doe',
path: '/users/john-doe',
component: 'pages/users/john-doe.vue'
}
]
}
You can find this example app in /chapter-4/nuxt-universal/routing/basic-routes/ in our GitHub repository.
You should be familiar with these basic routes from the previous chapter. This type of route is good for...