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:
Pooya Parsa 2017-08-10 15:07:23 +04:30
parent 71ebf02c6b
commit 7dd00a7c50
2 changed files with 5 additions and 3 deletions

View File

@ -1,11 +1,12 @@
<template>
<div id="__nuxt">
<% 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>
</template>
<script>
import Vue from 'vue'
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
<% css.forEach(function (c) { %>
import '<%= relativeToBuild(resolvePath(c.src || c)) %>'
@ -31,6 +32,9 @@ export default {
this.$nuxt.$loading = this.$loading
},
<% } %>
beforeCreate () {
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
},
methods: {
setLayout (layout) {
if (!layout || !layouts['_' + layout]) layout = 'default'

View File

@ -69,8 +69,6 @@ test('/test/env', async t => {
test('/test/error', async t => {
const window = await nuxt.renderAndGetWindow(url('/test/error'))
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'))
})