Use nuxtChildKey as computed by default

This commit is contained in:
Sébastien Chopin 2017-07-09 12:23:56 +02:00
parent a869637615
commit a963b566c1

View File

@ -1,6 +1,6 @@
<template>
<nuxt-error v-if="nuxt.err" :error="nuxt.err"></nuxt-error>
<nuxt-child :key="routerViewKey" v-else></nuxt-child>
<nuxt-child :key="nuxtChildKey" v-else></nuxt-child>
</template>
<script>
@ -46,6 +46,15 @@ export default {
}
},
<% } %>
computed: {
nuxtChildKey () {
// If routerViewKey prop is given or current route has children
if (typeof this.routerViewKey !== 'undefined' || this.$route.matched.length > 1) {
return this.routerViewKey || ''
}
return this.$route.fullPath.split('#')[0]
}
},
components: {
NuxtChild,
NuxtError