File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ const AsyncComputed = {
39
39
this . $options . computed [ prefix + key ] = getter
40
40
}
41
41
42
- this . $options . data = function vueAsyncComputedInjectedDataFn ( ) {
42
+ this . $options . data = function vueAsyncComputedInjectedDataFn ( vm ) {
43
43
const data = (
44
44
( typeof optionData === 'function' )
45
- ? optionData . call ( this )
45
+ ? optionData . call ( this , vm )
46
46
: optionData
47
47
) || { }
48
48
for ( const key in asyncComputed ) {
Original file line number Diff line number Diff line change @@ -868,3 +868,20 @@ test("Plain components with neither `data` nor `asyncComputed` still work (issue
868
868
} )
869
869
t . equal ( vm . a , 1 )
870
870
} )
871
+
872
+ test ( 'Data of component still work as function and got vm' , t => {
873
+ t . plan ( 1 )
874
+ let _vmContext = null
875
+ const vm = new Vue ( {
876
+ data ( vmContext ) {
877
+ _vmContext = vmContext
878
+ } ,
879
+ asyncComputed : {
880
+ async a ( ) {
881
+ return Promise . resolve ( 1 )
882
+ } ,
883
+ } ,
884
+
885
+ } )
886
+ t . equal ( vm , _vmContext )
887
+ } )
You can’t perform that action at this time.
0 commit comments