You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-12Lines changed: 11 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -275,15 +275,15 @@ new Vue({
275
275
276
276
### Conditional Recalculation
277
277
278
-
Using `watch` it is possible to run the computed property again but it will run regardless of the
279
-
value of the watched property. If you need more control over when the computation should be rerun
280
-
you can use `shouldUpdate`:
278
+
Using `watch` it is possible to force the computed property to run again unconditionally.
279
+
If you need more control over when the computation should be rerun you can use `shouldUpdate`:
280
+
281
281
```js
282
282
283
283
newVue({
284
284
data: {
285
285
postId:1,
286
-
// Imagine pageType can be one of 'index', 'details' and 'edit'
286
+
// Imagine pageType can be one of 'index', 'details' and 'edit'.
287
287
pageType:'index'
288
288
},
289
289
asyncComputed: {
@@ -292,10 +292,10 @@ new Vue({
292
292
returnVue.http.get('/post/'+this.postId)
293
293
.then(response=>response.data.postContent)
294
294
},
295
-
// Will update whenever the pageType or postId changes
296
-
// but only if the pageType is not 'index' this way the
297
-
// blogPostContent will be refetched when loading the
298
-
// 'details' and 'edit' pages
295
+
// Will update whenever the pageType or postId changes,
296
+
// but only if the pageType is not 'index'. This way the
297
+
// blogPostContent will be refetched only when loading the
298
+
// 'details' and 'edit' pages.
299
299
shouldUpdate () {
300
300
returnthis.pageType!=='index'
301
301
}
@@ -304,12 +304,11 @@ new Vue({
304
304
}
305
305
```
306
306
307
-
The main advantage over adding an if statement within the get function is that when the computation is
308
-
not rerun you are able to still access the old value.
307
+
The main advantage over adding an `if` statement within the get function is that the old value is still accessible even if the computation is not re-run.
309
308
310
309
## Lazy properties
311
310
312
-
Normally, computed properties are run both immediately, and as necessary when their dependencies change.
311
+
Normally, computed properties are both run immediately, and re-run as necessary when their dependencies change.
313
312
With async computed properties, you sometimes don't want that. With `lazy:true`, an async computed
314
313
property will only be computed the first time it's accessed.
315
314
@@ -367,7 +366,7 @@ new Vue({
367
366
// This will display a loading message every time the posts are updated:
0 commit comments