mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 17:43:59 +00:00
34 lines
972 B
Markdown
34 lines
972 B
Markdown
|
---
|
||
|
icon: IconDirectory
|
||
|
title: 'pages'
|
||
|
head.title: Pages directory
|
||
|
---
|
||
|
|
||
|
The `pages/` directory is optional, meaning that if you only use [app.vue](/docs/directory-structure/app), vue-router won't be included, reducing your application bundle size.
|
||
|
|
||
|
# Pages directory
|
||
|
|
||
|
Nuxt will automatically integrate [Vue Router](https://next.router.vuejs.org/) and map `pages/` directory into the routes of your application.
|
||
|
|
||
|
## Dynamic Routes
|
||
|
|
||
|
If you place anything within square brackets, it will be turned into a [dynamic route](https://next.router.vuejs.org/guide/essentials/dynamic-matching.html) parameter. You can mix and match multiple parameters and even non-dynamic text within a file name or directory.
|
||
|
|
||
|
### Example
|
||
|
|
||
|
```bash
|
||
|
-| pages/
|
||
|
---| index.vue
|
||
|
---| users-[group]/
|
||
|
-----| [id].vue
|
||
|
```
|
||
|
|
||
|
Given the example above, you can access group/id within your component via the `$route` object:
|
||
|
|
||
|
```vue
|
||
|
<template>
|
||
|
{{ $route.params.group }}
|
||
|
{{ $route.params.id }}
|
||
|
</template>
|
||
|
```
|