fix(vue-app): layout in error.vue not work for Vue.extend component (#6650)

This commit is contained in:
Xin Du (Clark) 2019-11-05 17:53:39 +00:00 committed by GitHub
parent 3948e606df
commit afb38fe492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 12 deletions

View File

@ -37,12 +37,15 @@ export default {
<% if (loading) { %>const loadingEl = h('NuxtLoading', { ref: 'loading' })<% } %>
<% if (features.layouts) { %>
<% if (components.ErrorPage) { %>
if (this.nuxt.err && NuxtError.layout) {
this.setLayout(
typeof NuxtError.layout === 'function'
? NuxtError.layout(this.context)
: NuxtError.layout
)
if (this.nuxt.err && NuxtError) {
const errorLayout = (NuxtError.options || NuxtError).layout
if (errorLayout) {
this.setLayout(
typeof errorLayout === 'function'
? errorLayout.call(NuxtError, this.context)
: errorLayout
)
}
}
<% } %>
const layoutEl = h(this.layout || 'nuxt')

View File

@ -315,10 +315,11 @@ async function render (to, from, next) {
<% if (features.layouts) { %>
// Load layout for error page
const errorLayout = (NuxtError.options || NuxtError).layout
const layout = await this.loadLayout(
typeof NuxtError.layout === 'function'
? NuxtError.layout(app.context)
: NuxtError.layout
typeof errorLayout === 'function'
? errorLayout.call(NuxtError, app.context)
: errorLayout
)
<% } %>
@ -523,7 +524,7 @@ async function render (to, from, next) {
<% if (features.layouts) { %>
// Load error layout
let layout = NuxtError.layout
let layout = (NuxtError.options || NuxtError).layout
if (typeof layout === 'function') {
layout = layout(app.context)
}
@ -558,7 +559,7 @@ function showNextPage (to) {
<% if (features.layouts) { %>
// Set layout
let layout = this.$options.nuxt.err
? NuxtError.layout
? (NuxtError.options || NuxtError).layout
: to.matched[0].components.default.options.layout
if (typeof layout === 'function') {

View File

@ -88,7 +88,8 @@ export default async (ssrContext) => {
const renderErrorPage = async () => {
<% if (features.layouts) { %>
// Load layout for error page
const errLayout = (typeof NuxtError.layout === 'function' ? NuxtError.layout(app.context) : NuxtError.layout)
const layout = (NuxtError.options || NuxtError).layout
const errLayout = typeof layout === 'function' ? layout.call(NuxtError, app.context) : layout
ssrContext.nuxt.layout = errLayout || 'default'
await _app.loadLayout(errLayout)
_app.setLayout(errLayout)