File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 11/* @flow */
22
33import type VueRouter from '../index'
4+ import { warn } from '../util/warn'
45import { inBrowser } from '../util/dom'
56import { runQueue } from '../util/async'
67import { isSameRoute } from '../util/route'
@@ -142,10 +143,21 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Array<?Function>
142143 // we want to halt the navigation until the incoming component has been
143144 // resolved.
144145 if ( typeof def === 'function' && ! def . options ) {
145- return ( route , redirect , next ) => def ( resolvedDef => {
146- match . components [ key ] = resolvedDef
147- next ( )
148- } )
146+ return ( route , redirect , next ) => {
147+ const resolve = resolvedDef => {
148+ match . components [ key ] = resolvedDef
149+ next ( )
150+ }
151+
152+ const reject = reason => {
153+ warn ( false , `Failed to resolve async component ${ key } : ${ reason } ` )
154+ }
155+
156+ const res = def ( resolve , reject )
157+ if ( res && typeof res . then === 'function' ) {
158+ res . then ( resolve , reject )
159+ }
160+ }
149161 }
150162 } )
151163}
You can’t perform that action at this time.
0 commit comments