2016-11-19 21:16:26 +00:00
|
|
|
<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>
|
2016-11-19 21:16:26 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2016-11-21 13:14:35 +00:00
|
|
|
import Vue from 'vue'
|
2016-12-16 16:45:47 +00:00
|
|
|
import NuxtChild from './nuxt-child'
|
2017-06-29 16:36:22 +00:00
|
|
|
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'
|
2016-11-19 21:16:26 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'nuxt',
|
2017-07-09 14:29:14 +00:00
|
|
|
props: ['nuxtChildKey'],
|
2016-11-21 13:14:35 +00:00
|
|
|
beforeCreate () {
|
|
|
|
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
2016-11-19 21:16:26 +00:00
|
|
|
},
|
2017-07-09 10:23:56 +00:00
|
|
|
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) {
|
2017-08-01 13:16:23 +00:00
|
|
|
return this.nuxtChildKey || compile(this.$route.matched[0].path)(this.$route.params)
|
2017-07-09 10:23:56 +00:00
|
|
|
}
|
|
|
|
return this.$route.fullPath.split('#')[0]
|
|
|
|
}
|
|
|
|
},
|
2016-11-19 21:16:26 +00:00
|
|
|
components: {
|
2016-12-16 16:45:47 +00:00
|
|
|
NuxtChild,
|
2017-01-30 10:20:20 +00:00
|
|
|
NuxtError
|
2016-11-19 21:16:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|