mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Should work with route not code-splitted
This commit is contained in:
parent
7146b0f2a8
commit
1f317a188b
@ -3,7 +3,7 @@
|
||||
import Vue from 'vue'
|
||||
import middleware from './middleware'
|
||||
import { createApp, NuxtError } from './index'
|
||||
import { applyAsyncData, getMatchedComponents, getMatchedComponentsInstances, flatMapComponents, getContext, middlewareSeries, promisify, getLocation, compile } from './utils'
|
||||
import { applyAsyncData, sanitizeComponent, getMatchedComponents, getMatchedComponentsInstances, flatMapComponents, getContext, middlewareSeries, promisify, getLocation, compile } from './utils'
|
||||
const noopData = () => { return {} }
|
||||
const noopFetch = () => {}
|
||||
let _lastPaths = []
|
||||
@ -26,20 +26,16 @@ function loadAsyncComponents (to, from, next) {
|
||||
if (typeof Component === 'function' && !Component.options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const _resolve = (Component) => {
|
||||
if (!Component.options) {
|
||||
Component = Vue.extend(Component) // fix issue #6
|
||||
Component._Ctor = Component
|
||||
} else {
|
||||
Component._Ctor = Component
|
||||
Component.extendOptions = Component.options
|
||||
}
|
||||
Component = sanitizeComponent(Component)
|
||||
match.components[key] = Component
|
||||
resolve(Component)
|
||||
}
|
||||
Component().then(_resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
return Component
|
||||
Component = sanitizeComponent(Component)
|
||||
match.components[key] = Component
|
||||
return match.components[key]
|
||||
})
|
||||
const fromPath = from.fullPath.split('#')[0]
|
||||
const toPath = to.fullPath.split('#')[0]
|
||||
@ -328,13 +324,7 @@ const resolveComponents = flatMapComponents(router.match(path), (Component, _, m
|
||||
if (typeof Component === 'function' && !Component.options) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const _resolve = (Component) => {
|
||||
if (!Component.options) {
|
||||
Component = Vue.extend(Component) // fix issue #6
|
||||
Component._Ctor = Component
|
||||
} else {
|
||||
Component._Ctor = Component
|
||||
Component.extendOptions = Component.options
|
||||
}
|
||||
Component = sanitizeComponent(Component)
|
||||
if (NUXT.serverRendered) {
|
||||
applyAsyncData(Component, NUXT.data[index])
|
||||
}
|
||||
@ -344,6 +334,8 @@ const resolveComponents = flatMapComponents(router.match(path), (Component, _, m
|
||||
Component().then(_resolve).catch(reject)
|
||||
})
|
||||
}
|
||||
Component = sanitizeComponent(Component)
|
||||
match.components[key] = Component
|
||||
return Component
|
||||
})
|
||||
|
||||
|
@ -50,6 +50,7 @@ export default async (context) => {
|
||||
let Components = []
|
||||
let promises = getMatchedComponents(router.match(context.url)).map((Component) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof Component !== 'function') return resolve(sanitizeComponent(Component))
|
||||
const _resolve = (Component) => resolve(sanitizeComponent(Component))
|
||||
Component().then(_resolve).catch(reject)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user