File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ const AsyncComputed = {
3939 this . $options . computed [ prefix + key ] = getter
4040 }
4141
42- this . $options . data = function vueAsyncComputedInjectedDataFn ( ) {
42+ this . $options . data = function vueAsyncComputedInjectedDataFn ( vm ) {
4343 const data = (
4444 ( typeof optionData === 'function' )
45- ? optionData . call ( this )
45+ ? optionData . call ( this , vm )
4646 : optionData
4747 ) || { }
4848 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
868868 } )
869869 t . equal ( vm . a , 1 )
870870} )
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