Skip to content

Commit 5197c4e

Browse files
committed
compat with new async component syntax
1 parent 199a98e commit 5197c4e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/history/base.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
321321
pending++
322322

323323
const resolve = once(resolvedDef => {
324+
// save resolved on async factory in case it's used elsewhere
325+
def.resolved = typeof resolvedDef === 'function'
326+
? resolvedDef
327+
: _Vue.extend(resolvedDef)
324328
match.components[key] = resolvedDef
325329
pending--
326330
if (pending <= 0 && _next) {
@@ -345,8 +349,16 @@ function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
345349
} catch (e) {
346350
reject(e)
347351
}
348-
if (res && typeof res.then === 'function') {
349-
res.then(resolve, reject)
352+
if (res) {
353+
if (typeof res.then === 'function') {
354+
res.then(resolve, reject)
355+
} else {
356+
// new syntax in Vue 2.3
357+
const comp = res.component
358+
if (comp && typeof comp.then === 'function') {
359+
comp.then(resolve, reject)
360+
}
361+
}
350362
}
351363
}
352364
})

0 commit comments

Comments
 (0)