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 1
1
/* @flow */
2
2
3
3
import type VueRouter from '../index'
4
+ import { warn } from '../util/warn'
4
5
import { inBrowser } from '../util/dom'
5
6
import { runQueue } from '../util/async'
6
7
import { isSameRoute } from '../util/route'
@@ -142,10 +143,21 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Array<?Function>
142
143
// we want to halt the navigation until the incoming component has been
143
144
// resolved.
144
145
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
+ }
149
161
}
150
162
} )
151
163
}
You can’t perform that action at this time.
0 commit comments