File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 22<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
33# Changelog
44
5- - [ 2.0.0] ( #200 )
5+ - [ v2.1.0] ( #v210 )
6+ - [ v2.0.0] ( #v200 )
67- [ v1.4.0] ( #v140 )
78- [ v1.2.0] ( #v120 )
89- [ v1.1.0] ( #v110 )
910- [ v1.0.0] ( #v100 )
1011
1112<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1213
13- ### 2.0.0
14+ ### v2.1.0
15+ * Allow object syntax for defining computed properties.
16+ * Enable custom default values
17+
18+ ### v2.0.0
1419 * Now compatible with Vue 2.0
1520
1621### v1.4.0
Original file line number Diff line number Diff line change @@ -141,6 +141,37 @@ const vm = new Vue({
141141*/
142142` ` ` `
143143
144+ [Like with regular synchronous computed properties](https: // vuejs.org/guide/computed.html#Computed-Setter), you can pass an object
145+ with a ` get` method instead of a function , but unlike regular computed
146+ properties, async computed properties are always getter-only. If the
147+ object provided has a `set` method it will be ignored.
148+
149+ Async computed properties can also have a custom default value, which will
150+ be used until the data is loaded for the first time:
151+
152+ ````js
153+ new Vue ({
154+ data: {
155+ postId: 1
156+ },
157+ asyncComputed: {
158+ blogPostContent: {
159+ read () {
160+ return Vue .http .get (' /post/' + this .postId )
161+ .then (response => response .data .postContent )
162+ },
163+ default: ' Loading...'
164+ }
165+ }
166+ }
167+
168+ /*
169+ Now you can display {{blogPostContent}} in your template, which
170+ will show a loading message until the blog post's content arrives
171+ from the server.
172+ */
173+ ` ` ` `
174+
144175## Options
145176
146177By default , in case of a rejected promise in an async computed property , vue - async - computed will take care of logging the error for you .
You can’t perform that action at this time.
0 commit comments