This repository was archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
docs(getting-started): add views page #7556
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
204cbe6
docs(wip): add views page
clemcode c46c1fc
chore: lint docs
clemcode 75d38f8
Merge branch 'main' into docs/getting-started/views
clemcode c9effe3
docs: add description for views page
clemcode beeba10
Merge branch 'docs/getting-started/views' of github.com:nuxt/frameworβ¦
clemcode 656646a
docs: add link to routing section
clemcode c377692
docs: remove hellonuxt component from example
clemcode 6caee73
docs: update layouts explanation
clemcode e972f28
docs: update layouts section
clemcode 76972ea
Merge branch 'main' into docs/getting-started/views
clemcode 32b6083
docs(views): add images
clemcode 7160b24
Merge branch 'main' into docs/getting-started/views
pi0 decd5e7
small tweaks
pi0 5842cfb
docs: tweaks
danielroe 8503bcb
Update docs/content/1.getting-started/3.views.md
pi0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
schema | ||
**/*.configuration/nuxt.config.md | ||
**/*.configuration/nuxt-config.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,130 @@ | ||
# Views | ||
|
||
::NeedContribution | ||
Nuxt provides several component layers to implement the user interface of your application. | ||
|
||
## `app.vue` | ||
|
||
 | ||
|
||
By default, Nuxt will treat this file as the **entrypoint** and render it's content for every route of the application. | ||
|
||
```vue [app.vue] | ||
<template> | ||
<div> | ||
<h1>Welcome to the homepage</h1> | ||
</div> | ||
</template> | ||
``` | ||
|
||
::alert | ||
If you are familiar with Vue, you might wonder where is the `main.js` file that creates a Vue app. Nuxt does this behind the scene. | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:: | ||
|
||
## Components | ||
|
||
 | ||
|
||
Most of the components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the `components/` directory for them to be automatically available across your application without having to explicitly import them. | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
::code-group | ||
|
||
```vue [App.vue] | ||
<template> | ||
<div> | ||
<h1>Welcome to the homepage</h1> | ||
<AppAlert> | ||
This is an auto-imported component. | ||
</AppAlert> | ||
</div> | ||
</template> | ||
``` | ||
|
||
```vue [components/AppAlert.vue] | ||
<template> | ||
<span> | ||
<slot /> | ||
</span> | ||
</template> | ||
``` | ||
|
||
:: | ||
|
||
## Pages | ||
|
||
 | ||
|
||
Pages represent views use for each specific route pattern. Every file in the `pages/` directory represents a different route displaying it's content. | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to the `app.vue` (or remove `app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the `pages/` directory. | ||
|
||
::code-group | ||
|
||
```vue [pages/index.vue] | ||
<template> | ||
<div> | ||
<h1>Welcome to the homepage</h1> | ||
<AppAlert> | ||
This is an auto-imported component | ||
</AppAlert> | ||
</div> | ||
</template> | ||
``` | ||
|
||
```vue [pages/about.vue] | ||
<template> | ||
<section> | ||
<p>This page will be displayed at the /about route.</p> | ||
</section> | ||
</template> | ||
``` | ||
|
||
:: | ||
|
||
::ReadMore{link="/guide/directory-structure/components"} | ||
::alert | ||
You will learn more about pages in the [Routing section](/getting-started/routing) | ||
:: | ||
|
||
::ReadMore{link="/guide/directory-structure/pages"} | ||
## Layouts | ||
|
||
 | ||
|
||
Layouts are wrapper around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `<slot />` components to display the **pages** content. The `layout/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata. | ||
danielroe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
::alert | ||
If you only have a single layout in your application, we recommend using app.vue with the [`<NuxtPage />` component](/api/components/nuxt-page) instead. | ||
:: | ||
|
||
::ReadMore{link="/guide/directory-structure/layouts"} | ||
::code-group | ||
|
||
```vue [layouts/default.vue] | ||
<template> | ||
<div> | ||
<AppHeader /> | ||
<slot /> | ||
<AppFooter /> | ||
</div> | ||
</template> | ||
``` | ||
|
||
```vue [pages/index.vue] | ||
<template> | ||
<div> | ||
<h1>Welcome to the homepage</h1> | ||
<AppAlert> | ||
This is an auto-imported component | ||
</AppAlert> | ||
</div> | ||
</template> | ||
``` | ||
|
||
```vue [pages/about.vue] | ||
<template> | ||
<section> | ||
<p>This page will be displayed at the /about route.</p> | ||
</section> | ||
</template> | ||
``` | ||
|
||
:: | ||
|
||
If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/guide/directory-structure/layouts). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.