fix(vue-app): fallback to global nuxt instance of $root is not available (#9008)

This commit is contained in:
vcordes79 2021-03-31 19:52:32 +02:00 committed by GitHub
parent b602cfa2be
commit c04a793b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,11 @@ Vue.component(Nuxt.name, Nuxt)
Object.defineProperty(Vue.prototype, '<%= globals.nuxt %>', {
get() {
return this.$root.$options.<%= globals.nuxt %>
const globalNuxt = this.$root.$options.<%= globals.nuxt %>
if (process.client && !globalNuxt && typeof window !== 'undefined') {
return window.<%= globals.nuxt %>
}
return globalNuxt
},
configurable: true
})