Fix: error on template for layout when redirected

This commit is contained in:
Sébastien Chopin 2017-06-04 19:59:36 +02:00
parent b26d3d6b6f
commit ce69c3be0f

View File

@ -19,6 +19,7 @@ const isDev = <%= isDev %>
export default async (context) => { export default async (context) => {
const { app, router<%= (store ? ', store' : '') %> } = await createApp(context) const { app, router<%= (store ? ', store' : '') %> } = await createApp(context)
const _app = new Vue(app) const _app = new Vue(app)
const _noopApp = new Vue({ render: (h) => h('div') })
// Add store to the context // Add store to the context
<%= (store ? 'context.store = store' : '') %> <%= (store ? 'context.store = store' : '') %>
// Add route to the context // Add route to the context
@ -82,7 +83,7 @@ export default async (context) => {
if (!context.nuxt.error) { if (!context.nuxt.error) {
await middlewareSeries(midd, ctx) await middlewareSeries(midd, ctx)
} }
if (context.redirected) return _app if (context.redirected) return _noopApp
// Set layout // Set layout
let layout = Components.length ? Components[0].options.layout : NuxtError.layout let layout = Components.length ? Components[0].options.layout : NuxtError.layout
if (typeof layout === 'function') layout = layout(ctx) if (typeof layout === 'function') layout = layout(ctx)
@ -107,7 +108,7 @@ export default async (context) => {
if (!context.nuxt.error) { if (!context.nuxt.error) {
await middlewareSeries(midd, ctx) await middlewareSeries(midd, ctx)
} }
if (context.redirected) return _app if (context.redirected) return _noopApp
// Call .validate() // Call .validate()
let isValid = true let isValid = true
Components.forEach((Component) => { Components.forEach((Component) => {