mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
rewrite nuxt.vue with render function
This commit is contained in:
parent
870cbd6278
commit
e4af41f529
@ -1,10 +1,3 @@
|
||||
<template>
|
||||
<div class="nuxt">
|
||||
<nuxt-error v-if="nuxt.err" :error="nuxt.err"></nuxt-error>
|
||||
<nuxt-child :key="routerViewKey" v-else></nuxt-child>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import NuxtChild from './nuxt-child'
|
||||
@ -14,6 +7,20 @@ import { compile } from '../utils'
|
||||
export default {
|
||||
name: 'nuxt',
|
||||
props: ['nuxtChildKey'],
|
||||
render(h) {
|
||||
// If there is some error
|
||||
if (this.nuxt.err) {
|
||||
return h('nuxt-error', {
|
||||
props: {
|
||||
error: this.nuxt.err
|
||||
}
|
||||
})
|
||||
}
|
||||
// Directly return nuxt child
|
||||
return h('nuxt-child', {
|
||||
key: this.routerViewKey
|
||||
})
|
||||
},
|
||||
beforeCreate () {
|
||||
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user