fix NUXT.data for SPA

This commit is contained in:
Pooya Parsa 2017-09-07 17:06:45 +04:30
parent 9a28b8be25
commit 4d5255e805

View File

@ -146,14 +146,14 @@ function resolveComponents(router) {
return flatMapComponents(router.match(path), (Component, _, match, key, index) => {
// If component already resolved
if (typeof Component !== 'function' || Component.options) {
const _Component = applySSRData(sanitizeComponent(Component), NUXT.data[index])
const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null)
match.components[key] = _Component
return _Component
}
// Resolve component
return Component().then(Component => {
const _Component = applySSRData(sanitizeComponent(Component), NUXT.data[index])
const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null)
match.components[key] = _Component
return _Component
})