mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix: Handle synchronous route component
This commit is contained in:
parent
226a8701b4
commit
74bc12da51
@ -26,7 +26,6 @@ let router
|
||||
|
||||
// Try to rehydrate SSR data from window
|
||||
const NUXT = window.__NUXT__ || {}
|
||||
NUXT.components = window.__COMPONENTS__ || null
|
||||
|
||||
<% if (debug || mode === 'spa') { %>
|
||||
// Setup global Vue error handler
|
||||
@ -132,6 +131,14 @@ async function loadAsyncComponents (to, from, next) {
|
||||
}
|
||||
}
|
||||
|
||||
function applySSRData(Component) {
|
||||
if (NUXT.serverRendered) {
|
||||
applyAsyncData(Component, NUXT.data[index])
|
||||
Component._Ctor = Component
|
||||
}
|
||||
return Component
|
||||
}
|
||||
|
||||
// Get matched components
|
||||
function resolveComponents(router) {
|
||||
const path = getLocation(router.options.base, router.options.mode)
|
||||
@ -139,23 +146,16 @@ function resolveComponents(router) {
|
||||
return flatMapComponents(router.match(path), (Component, _, match, key, index) => {
|
||||
// If component already resolved
|
||||
if (typeof Component !== 'function' || Component.options) {
|
||||
const _Component = sanitizeComponent(Component)
|
||||
const _Component = applySSRData(sanitizeComponent(Component))
|
||||
match.components[key] = _Component
|
||||
return _Component
|
||||
}
|
||||
|
||||
// Resolve component
|
||||
return Component().then(Component => {
|
||||
const _Component = sanitizeComponent(Component)
|
||||
if (NUXT.serverRendered) {
|
||||
applyAsyncData(_Component, NUXT.data[index])
|
||||
if (NUXT.components) {
|
||||
Component.options.components = Object.assign(_Component.options.components, NUXT.components[index])
|
||||
}
|
||||
_Component._Ctor = _Component
|
||||
}
|
||||
match.components[key] = _Component
|
||||
return _Component
|
||||
const _Component = applySSRData(sanitizeComponent(Component))
|
||||
match.components[key] = _Component
|
||||
return _Component
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user