Skip to content

Commit d19c6bd

Browse files
committed
state.md - code sample for state definition
I am actually following the guide and missed a basic code sample like this...
1 parent 4415345 commit d19c6bd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/en/state.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ Vuex uses a **single state tree** - that is, this single object contains all you
66

77
The single state tree does not conflict with modularity - in later chapters we will discuss how to split your state managing logic into sub modules.
88

9+
### Setting State in a Vuex Store
10+
11+
This is a very basic example where the `state` object is initialized with a single `message` property containing the `Hello, Store` string:
12+
13+
``` js
14+
import Vuex from 'vuex'
15+
16+
const store = new Vuex.Store({
17+
state: {
18+
message: 'Hello, Store'
19+
}
20+
})
21+
```
22+
923
### Getting Vuex State into Vue Components
1024

1125
Similar to `data` objects passed to Vue instances, the `state` object, once passed into a Vuex store, becomes reactive powered by [Vue's reactivity system](http://vuejs.org/guide/reactivity.html). This means binding Vuex state to Vue components is as simple as returning it from within a computed property:

0 commit comments

Comments
 (0)