You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/forms.md
+7-8Lines changed: 7 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
-
# Form Handling
1
+
# Gestion des formulaires
2
2
3
-
When using Vuex in strict mode, it could be a bit tricky to use `v-model`on a piece of state that belongs to Vuex:
3
+
Lorsque l'on utilise Vuex en mode strict, il peut être compliqué d'utiliser `v-model`sur une partie de l'état qui appartient à Vuex:
4
4
5
5
```html
6
6
<inputv-model="obj.message">
7
7
```
8
8
9
-
Assuming `obj`is a computed property that returns an Object from the store, the`v-model`here will attempt to directly mutate `obj.message`when the user types in the input. In strict mode, this will result in an error because the mutation is not performed inside an explicit Vuex mutation handler.
9
+
Supposons que `obj`est une propriété calculée qui retourne un objet depuis le store, le`v-model`tentera de muter directement `obj.message`lorsque l'utilisateur saisit du texte dans le champ. En mode strict, cela produira une erreur car la mutation n'est pas effectuée dans un gestionnaire de mutation Vuex explicite.
10
10
11
-
The "Vuex way" to deal with it is binding the `<input>`'s value and call an action on the`input`or`change`event:
11
+
La « méthode Vuex » pour gérer ça est de lier la valeur de l'`input` et d'appeler une action sur l'évènement`input`ou`change` :
12
12
13
13
```html
14
14
<input:value="message"@input="updateMessage">
@@ -27,7 +27,7 @@ methods: {
27
27
}
28
28
```
29
29
30
-
And here's the mutation handler:
30
+
Et voici le gestionnaire de mutation :
31
31
32
32
```js
33
33
// ...
@@ -38,9 +38,9 @@ mutations: {
38
38
}
39
39
```
40
40
41
-
### Two-way Computed Property
41
+
### Propriété calculée bidirectionnelle
42
42
43
-
Admittedly, the above is quite a bit more verbose than `v-model`+ local state, and we lose some of the useful features from `v-model`as well. An alternative approach is using a two-way computed property with a setter:
43
+
Admettons tout de même que l'exemple ci-dessus est plus verbeux que le `v-model`couplé à l'état local (tout en perdant quelques fonctionnalités pratiques de `v-model`au passage). Une approche alternative consiste à utiliser une propriété calculée bidirectionnelle avec un mutateur :
0 commit comments