瀏覽代碼

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

Dave Stewart 7 年之前
父節點
當前提交
f61a69c0f4
共有 1 個文件被更改,包括 9 次插入1 次删除
  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: