mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +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>
|
<script>
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import NuxtChild from './nuxt-child'
|
import NuxtChild from './nuxt-child'
|
||||||
@ -14,6 +7,20 @@ import { compile } from '../utils'
|
|||||||
export default {
|
export default {
|
||||||
name: 'nuxt',
|
name: 'nuxt',
|
||||||
props: ['nuxtChildKey'],
|
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 () {
|
beforeCreate () {
|
||||||
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user