State | vue mutation map
![State](https://i.imgur.com/axBPWDg.jpg)
SingleStateTreeVuexusesasinglestatetree-thatis,thissingleobjectcontainsallyourapplicationlevelstateandservesasthe"singlesourceoftruth."Thisalsomeansusuallyyouwillhaveonlyonestoreforeachapplication.Asinglestatetreemakesitstraightforwardtolocateaspecificpieceofstate,andallowsustoeasilytakesnapshotsofthecurrentappstatefordebuggingpurposes.Thesinglestatetreedoesnotconflictwithmodularity-inlaterchapterswewilldiscusshowtosplityourstateandmutationsintosubmodules.ThedatayoustoreinVuexfollowsthesamer...
![State](http://pix4.agoda.net/hotelimages/agoda-homes/5899847/61e1a790eeb181e40e8f262ea5a396dc.jpg?s=800x)
Vuex uses a single state tree - that is, this single object contains all your application level state and serves as the "single source of truth." This also means usually you will have only one store for each application. A single state tree makes it straightforward to locate a specific piece of state, and allows us to easily take snapshots of the current app state for debugging purposes.
The single state tree does not conflict with modularity - in later chapters we will discuss how to split your state and mutations into sub modules.
The data you store in Vuex follows the same rules as the data in a Vue instance, ie the state object must be plain. See also: Vue#data[1].
Getting Vuex State into Vue ComponentsSo how do we display state inside the store in our Vue components? Since Vuex stores are reactive, the simplest way to "retrieve" state from it is simply returning some store state from within a computed property[2]:
const Counter = { tem...取得本站獨家住宿推薦 15%OFF 訂房優惠
本站住宿推薦 20%OFF 訂房優惠,親子優惠,住宿折扣,限時回饋,平日促銷
Mutations | vue mutation map
Actions | vue mutation map
Modules | vue mutation map
State | vue mutation map
Vuex mapMutations - How does it work? | vue mutation map
How can I mutate my module store state using map mutations from a ... | vue mutation map
Vuex Map Helpers | vue mutation map
vuex-map | vue mutation map
maoberlehnervuex-map-fields: Enable two | vue mutation map
[Vue.js] Vuex 學習筆記(7) | vue mutation map
Best practices for Vuex mapping | vue mutation map
Vuejs : mapMutations | vue mutation map
vuex (2) | vue mutation map
![](https://i.imgur.com/axBPWDg.jpg)