Procházet zdrojové kódy

Made getter property vs method syntax more explicit (#1169)

Dave Stewart před 7 roky
rodič
revize
f61a69c0f4
1 změnil soubory, kde provedl 9 přidání a 1 odebrání
  1. 9 1
      docs/en/getters.md

+ 9 - 1
docs/en/getters.md

@@ -32,7 +32,9 @@ const store = new Vuex.Store({
 })
 ```
 
-The getters will be exposed on the `store.getters` object:
+### Property-Style Access
+
+The getters will be exposed on the `store.getters` object, and you access values as properties:
 
 ``` js
 store.getters.doneTodos // -> [{ id: 1, text: '...', done: true }]
@@ -63,6 +65,10 @@ computed: {
 }
 ```
 
+Note that getters accessed as properties are cached as part of Vue's reactivity system.
+
+### Method-Style Access
+
 You can also pass arguments to getters by returning a function. This is particularly useful when you want to query an array in the store:
 
 ```js
@@ -78,6 +84,8 @@ getters: {
 store.getters.getTodoById(2) // -> { id: 2, text: '...', done: false }
 ```
 
+Note that getters accessed via methods will run each time you call them, and the result is not cached.
+
 ### The `mapGetters` Helper
 
 The `mapGetters` helper simply maps store getters to local computed properties: