mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix error pages layout
error page itself is a kind of layout so we should purely render it to avoid style conflicts
This commit is contained in:
parent
71ebf02c6b
commit
7dd00a7c50
@ -1,11 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="__nuxt">
|
<div id="__nuxt">
|
||||||
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
|
<% if (loading) { %><nuxt-loading ref="loading"></nuxt-loading><% } %>
|
||||||
<component v-if="layout" :is="layout"></component>
|
<component v-if="layout" :is="nuxt.err ? 'nuxt' : layout"></component>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Vue from 'vue'
|
||||||
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
|
||||||
<% css.forEach(function (c) { %>
|
<% css.forEach(function (c) { %>
|
||||||
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
|
||||||
@ -31,6 +32,9 @@ export default {
|
|||||||
this.$nuxt.$loading = this.$loading
|
this.$nuxt.$loading = this.$loading
|
||||||
},
|
},
|
||||||
<% } %>
|
<% } %>
|
||||||
|
beforeCreate () {
|
||||||
|
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setLayout (layout) {
|
setLayout (layout) {
|
||||||
if (!layout || !layouts['_' + layout]) layout = 'default'
|
if (!layout || !layouts['_' + layout]) layout = 'default'
|
||||||
|
@ -69,8 +69,6 @@ test('/test/env', async t => {
|
|||||||
test('/test/error', async t => {
|
test('/test/error', async t => {
|
||||||
const window = await nuxt.renderAndGetWindow(url('/test/error'))
|
const window = await nuxt.renderAndGetWindow(url('/test/error'))
|
||||||
const html = window.document.body.innerHTML
|
const html = window.document.body.innerHTML
|
||||||
t.is(window.__NUXT__.layout, 'custom')
|
|
||||||
t.true(html.includes('<h1>Custom layout</h1>'))
|
|
||||||
t.true(html.includes('Error page'))
|
t.true(html.includes('Error page'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user