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 936
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
27 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,27 @@ | ||
--- | ||
title: JSX | ||
description: Commen utiliser JSX avec Nuxt.js? | ||
--- | ||
|
||
# Comment utiliser JSX? | ||
|
||
Nuxt.js utilise le preset [babel-preset-vue-app](https://github.com/vuejs/babel-preset-vue-app) officiel comme configuration de défaut afin de pouvoir utiliser JSX dans vos composants. | ||
|
||
Vous pouvez utiliser JSX dans la méthode `render` de vos composants: | ||
|
||
```html | ||
<script> | ||
export default { | ||
data () { | ||
return { name: 'World' } | ||
}, | ||
render (h) { | ||
return <h1 class="red">{this.name}</h1> | ||
} | ||
} | ||
</script> | ||
``` | ||
|
||
<p class="Alert Alert--info">Créer un alias `h` pour `createElement` est une convention commune que vous rencontrerez dans l'écosystème Vue et est nécessaire pour JSX. Si `h` n'est pas disponible dans le scope, **votre application reportera une erreur**.</p> | ||
|
||
Vous pouvez en savoir plus dans la [section JSX] (https://vuejs.org/v2/guide/render-function.html#JSX) de la documentation Vue.js. |