forked from sveltejs/svelte.dev
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
7fedd8d
commit b8080c3
Showing
11 changed files
with
59 additions
and
47 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ev/content/tutorial/01-svelte/06-bindings/01-text-inputs/+assets/app-a/src/lib/App.svelte
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<script> | ||
let name = $state('world'); | ||
let name = $state('tout le monde'); | ||
</script> | ||
|
||
<input value={name} /> | ||
|
||
<h1>Hello {name}!</h1> | ||
<h1>Bonjour {name} !</h1> |
4 changes: 2 additions & 2 deletions
4
...ev/content/tutorial/01-svelte/06-bindings/01-text-inputs/+assets/app-b/src/lib/App.svelte
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<script> | ||
let name = $state('world'); | ||
let name = $state('tout le monde'); | ||
</script> | ||
|
||
<input bind:value={name} /> | ||
|
||
<h1>Hello {name}!</h1> | ||
<h1>Bonjour {name} !</h1> |
16 changes: 11 additions & 5 deletions
16
apps/svelte.dev/content/tutorial/01-svelte/06-bindings/01-text-inputs/index.md
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
--- | ||
title: Text inputs | ||
title: Inputs texte | ||
--- | ||
|
||
As a general rule, data flow in Svelte is _top down_ — a parent component can set props on a child component, and a component can set attributes on an element, but not the other way around. | ||
De manière générale, la donnée circule en _descendant_ — un composant parent peut définir des props | ||
sur un composant enfant, et un composant peut définir des attributs sur un élément, mais pas | ||
l'inverse. | ||
|
||
Sometimes it's useful to break that rule. Take the case of the `<input>` element in this component — we _could_ add an `oninput` event handler that sets the value of `name` to `event.target.value`, but it's a bit... boilerplatey. It gets even worse with other form elements, as we'll see. | ||
Parfois, il peut être utile d'ignorer cette règle. Prenez le cas du élément `<input>` dans ce | ||
composant — nous _pourrions_ ajouter un gestionnaire d'évènement `oninput` qui définit la valeur de | ||
`name` à `event.target.value`, mais ça semble un peu... compliqué. Et ça peut empirer avec d'autres | ||
éléments de formulaires, comme nous le verrons plus tard. | ||
|
||
Instead, we can use the `bind:value` directive: | ||
Au lieu de faire ça, nous pouvons utiliser la directive `bind:value` : | ||
|
||
```svelte | ||
/// file: App.svelte | ||
<input +++bind:+++value={name}> | ||
``` | ||
|
||
This means that not only will changes to the value of `name` update the input value, but changes to the input value will update `name`. | ||
Ceci signifie que non seulement les changements de valeur de `name` vont mettre à jour la valeur de | ||
l'input, mais aussi que les changements sur la valeur de l'input vont mettre à jour `name`. |
8 changes: 5 additions & 3 deletions
8
apps/svelte.dev/content/tutorial/01-svelte/06-bindings/02-numeric-inputs/index.md
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
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
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
5 changes: 3 additions & 2 deletions
5
apps/svelte.dev/content/tutorial/01-svelte/06-bindings/03-checkbox-inputs/index.md
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
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
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
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
2 changes: 1 addition & 1 deletion
2
apps/svelte.dev/content/tutorial/01-svelte/06-bindings/index.md
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Bindings | ||
title: Liaisons | ||
scope: { 'prefix': '/src/lib/', 'name': 'src' } | ||
focus: /src/lib/App.svelte | ||
--- |