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/api/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,7 +185,7 @@ const store = new Vuex.Store({ ...options })
185
185
})
186
186
```
187
187
188
-
By default, new handler is added to the end of the chain, so it will be executed after other handlers that were added before. This can be overriden by adding `prepend:true` to `options`, which will add the handler to the beginning of the chain.
188
+
By default, new handler is added to the end of the chain, so it will be executed after other handlers that were added before. This can be overridden by adding `prepend:true` to `options`, which will add the handler to the beginning of the chain.
189
189
190
190
``` js
191
191
store.subscribe(handler, { prepend:true })
@@ -210,7 +210,7 @@ const store = new Vuex.Store({ ...options })
210
210
})
211
211
```
212
212
213
-
By default, new handler is added to the end of the chain, so it will be executed after other handlers that were added before. This can be overriden by adding `prepend:true` to `options`, which will add the handler to the beginning of the chain.
213
+
By default, new handler is added to the end of the chain, so it will be executed after other handlers that were added before. This can be overridden by adding `prepend:true` to `options`, which will add the handler to the beginning of the chain.
Copy file name to clipboardExpand all lines: docs/fr/guide/modules.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ Pour y remédier, Vuex nous permet de diviser notre store en **modules**. Chaque
8
8
9
9
```js
10
10
constmoduleA= {
11
-
state: { ... },
11
+
state:() => ({ ... }),
12
12
mutations: { ... },
13
13
actions: { ... },
14
14
getters: { ... }
15
15
}
16
16
17
17
constmoduleB= {
18
-
state: { ... },
18
+
state:() => ({ ... }),
19
19
mutations: { ... },
20
20
actions: { ... }
21
21
}
@@ -37,7 +37,9 @@ Dans les mutations et accesseurs d'un module, le premier argument reçu sera **l
37
37
38
38
```js
39
39
constmoduleA= {
40
-
state: { count:0 },
40
+
state: () => ({
41
+
count:0
42
+
}),
41
43
mutations: {
42
44
increment (state) {
43
45
// `state` est l'état du module local
@@ -87,14 +89,14 @@ Par défaut, les actions, mutations et accesseurs à l'intérieur d'un module so
87
89
88
90
Si vous souhaitez que votre module soit autosuffisant et réutilisable, vous pouvez le ranger sous un espace de nom avec `namespaced: true`. Quand le module est enregistré, tous ses accesseurs, actions et mutations seront automatiquement basés sur l'espace de nom du module dans lesquels ils sont rangés. Par exemple :
89
91
90
-
```js
92
+
```js
91
93
conststore=newVuex.Store({
92
94
modules: {
93
95
account: {
94
96
namespaced:true,
95
97
96
98
// propriétés du module
97
-
state: { ... }, // l'état du module est déjà imbriqué et n'est pas affecté par l'option `namespace`
99
+
state:() => ({ ... }), // l'état du module est déjà imbriqué et n'est pas affecté par l'option `namespace`
@@ -119,7 +121,7 @@ const store = new Vuex.Store({
119
121
posts: {
120
122
namespaced:true,
121
123
122
-
state: { ... },
124
+
state:() => ({ ... }),
123
125
getters: {
124
126
popular () { ... } // -> getters['account/posts/popular']
125
127
}
@@ -262,7 +264,7 @@ export default {
262
264
263
265
Vous devez faire attention au nom d'espace imprévisible pour vos modules quand vous créez un [plugin](./plugins.md) qui fournit les modules et laisser les utilisateurs les ajouter au store de Vuex. Vos modules seront également sous espace de nom si l'utilisateur du plugin l'ajoute sous un module sous espace de nom. Pour vous adapter à la situation, vous devez recevoir la valeur de l'espace de nom via vos options de plugin :
264
266
265
-
```js
267
+
```js
266
268
// passer la valeur d'espace de nom via une option du plugin
267
269
// et retourner une fonction de plugin Vuex
268
270
exportfunctioncreatePlugin (options= {}) {
@@ -311,11 +313,9 @@ C'est exactement le même problème qu'avec `data` dans un composant Vue. Ainsi
0 commit comments