Skip to content

Commit 8e5107d

Browse files
kazuponchrisvfritz
authored andcommitted
Revert "cache option for computed properties." (#728)
* Revert "`cache` option for computed properties." * re-emphasize computed update caveat
1 parent 115d6dc commit 8e5107d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/v2/api/index.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,15 @@ type: api
439439

440440
### computed
441441

442-
- **Type:** `{ [key: string]: Function | { get: Function, set: Function, cache: Boolean } }`
442+
- **Type:** `{ [key: string]: Function | { get: Function, set: Function } }`
443443

444444
- **Details:**
445445

446446
Computed properties to be mixed into the Vue instance. All getters and setters have their `this` context automatically bound to the Vue instance.
447447

448448
<p class="tip">Note that __you should not use an arrow function to define a computed property__ (e.g. `aDouble: () => this.a * 2`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.</p>
449449

450-
Computed properties are cached, and only re-computed on reactive dependency changes. Note that if a certain dependency is out of the instance's scope (i.e. not reactive), the computed property will not be updated. In this situation, caching can be turned off by setting `cache: false`. However, since the dependency is still not reactive, modifying it will not trigger a DOM update.
451-
452-
In most situations, `cache: false` will not be an ideal solution. Whenever possible, it's much better to pull external data into the reactivity system. For example, if a computed property depends on the size of the window, you can store this information in `data`, then use the `resize` event to keep the value up-to-date. Now it's reactive!
450+
Computed properties are cached, and only re-computed on reactive dependency changes. Note that if a certain dependency is out of the instance's scope (i.e. not reactive), the computed property will __not__ be updated.
453451

454452
- **Example:**
455453

0 commit comments

Comments
 (0)