Nuxt/lib/app/components/nuxt.vue

35 lines
1.0 KiB
Vue
Raw Normal View History

<template>
2017-09-09 11:12:07 +00:00
<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'
2016-12-16 16:45:47 +00:00
import NuxtChild from './nuxt-child'
import NuxtError from '<%= components.ErrorPage ? ((components.ErrorPage.includes('~') || components.ErrorPage.includes('@')) ? components.ErrorPage : "../" + components.ErrorPage) : "./nuxt-error.vue" %>'
2017-08-01 13:34:14 +00:00
import { compile } from '../utils'
export default {
name: 'nuxt',
2017-07-09 14:29:14 +00:00
props: ['nuxtChildKey'],
beforeCreate () {
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
},
computed: {
2017-07-09 14:29:14 +00:00
routerViewKey () {
// If nuxtChildKey prop is given or current route has children
if (typeof this.nuxtChildKey !== 'undefined' || this.$route.matched.length > 1) {
return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params)
}
return this.$route.fullPath.split('#')[0]
}
},
components: {
2016-12-16 16:45:47 +00:00
NuxtChild,
NuxtError
}
}
</script>