This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: "API: la méthode head" | ||
description: Nuxt.js utilise vue-meta pour mettre à jours les `headers` et les attributs html de votre application. | ||
--- | ||
|
||
# La méthode head | ||
|
||
> Nuxt.js utilise [vue-meta](https://github.com/declandewet/vue-meta) pour mettre à jours les `headers` et les attributs html de votre application. | ||
- **Type:** `Object` ou `Function` | ||
|
||
Utilisez la méthode `head` pour définir les tags HTML head de la page courante. | ||
|
||
Les données de votre composant sont disponibles avec `with` au sein de la méthode `head`, vous pouvez définir des meta tags personnalisés avec les données de page. | ||
|
||
```html | ||
<template> | ||
<h1>{{ title }}</h1> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
title: 'Hello World!' | ||
} | ||
}, | ||
head () { | ||
return { | ||
title: this.title, | ||
meta: [ | ||
{ hid: 'description', name: 'description', content: 'My custom description' } | ||
] | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
|
||
<p class="Alert">Afin d'éviter un doublon quand vous utilisez un composant enfant, utilisez un identifiant unique à l'aide de la clef `hid`; [plus à ce propos](https://github.com/declandewet/vue-meta#lists-of-tags).</p> |