Skip to content

Commit 1d906fd

Browse files
committed
[docs] forms
1 parent 2d34db8 commit 1d906fd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

docs/en/forms.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ Assuming `obj` is a computed property that returns an Object from the store, the
1111
The "Vuex way" to deal with it is binding the `<input>`'s value and call an action on the `input` or `change` event:
1212

1313
``` html
14-
<input :value="obj.message" @input="updateMessage">
14+
<input :value="message" @input="updateMessage">
1515
```
1616
``` js
1717
// ...
18-
methods: {
19-
updateMessage: function (e) {
20-
store.actions.updateMessage(e.target.value)
18+
vuex: {
19+
state: {
20+
message: state => state.obj.message
21+
},
22+
actions: {
23+
updateMessage: (store, e) => {
24+
store.dispatch('UPDATE_MESSAGE', e.target.value)
25+
}
2126
}
2227
}
2328
```
2429

25-
Assuming the `updateMessage` action simply dispatches `'UPDATE_MESSAGE'`, here's the mutation handler:
30+
And here's the mutation handler:
2631

2732
``` js
2833
// ...

0 commit comments

Comments
 (0)