فهرست منبع

Merge pull request #65 from jbruni/patch-2

state.md - code sample for state definition
Evan You 9 سال پیش
والد
کامیت
cb6bda3469
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  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.
 
+### Setting Initial 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
 
 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: