From 8abdc177beec2f09eb1e7909bdba5d9afe6015ec Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 30 Sep 2020 11:16:16 +0100 Subject: [PATCH] fix(vue-app): use mixin to provide `this.$nuxt` (#8068) Co-authored-by: Clark Du --- packages/vue-app/template/server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/vue-app/template/server.js b/packages/vue-app/template/server.js index a7a13e3638..2875bc6d54 100644 --- a/packages/vue-app/template/server.js +++ b/packages/vue-app/template/server.js @@ -24,6 +24,14 @@ if (!Vue.__nuxt__fetch__mixin__) { } <% } %> +Vue.mixin({ + beforeCreate() { + if(Vue.prototype.<%= globals.nuxt %>) { + this.<%= globals.nuxt %> = Vue.prototype.<%= globals.nuxt %> + } + } +}) + // Component: Vue.component(NuxtLink.name, NuxtLink) <% if (features.componentAliases) { %>Vue.component('NLink', NuxtLink)<% } %>