Nuxt/lib/app/components/nuxt.vue

33 lines
1021 B
Vue
Raw Normal View History

<template>
2017-02-09 23:47:35 +00:00
<nuxt-error v-if="nuxt.err" :error="nuxt.err"></nuxt-error>
2017-07-09 14:29:14 +00:00
<nuxt-child :key="routerViewKey" v-else></nuxt-child>
</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>