Bläddra i källkod

state.md - code sample for state definition

I am actually following the guide and missed a basic code sample like this...
J Bruni 9 år sedan
förälder
incheckning
d19c6bd4a8
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      docs/en/state.md

+ 14 - 0
docs/en/state.md

@@ -6,6 +6,20 @@ Vuex uses a **single state tree** - that is, this single object contains all you
 
 
 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.
 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.
 
 
+### Setting State in a Vuex Store
+
+This is a very basic example where the `state` object is initialized with a single `message` property containing the `Hello, Store` string:
+
+``` js
+import Vuex from 'vuex'
+
+const store = new Vuex.Store({
+  state: {
+    message: 'Hello, Store'
+  }
+})
+```
+
 ### Getting Vuex State into Vue Components
 ### Getting Vuex State into Vue Components
 
 
 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:
 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: