From a055b4b04782018b271df48b1b901df3eec5b165 Mon Sep 17 00:00:00 2001 From: Dizzy Rogers <19627670+Diizzayy@users.noreply.github.com> Date: Wed, 16 Feb 2022 20:18:31 +0000 Subject: [PATCH] fix: apply subsequent meta changes --- .../nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts b/packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts index 7f750ba4af6..97dc3eadd2a 100644 --- a/packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts +++ b/packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts @@ -7,7 +7,12 @@ export default defineNuxtPlugin((nuxtApp) => { const head = createHead() nuxtApp.vueApp.use(head) - nuxtApp.hooks.hookOnce('app:mounted', () => { watchEffect(() => head.updateDOM()) }) + + let headReady = false + nuxtApp.hooks.hookOnce('app:mounted', () => { + watchEffect(() => { head.updateDOM() }) + headReady = true + }) nuxtApp._useMeta = (meta: MetaObject) => { const headObj = ref(meta as any) @@ -15,11 +20,16 @@ export default defineNuxtPlugin((nuxtApp) => { if (process.server) { return } + if (headReady) { + watchEffect(() => { head.updateDOM() }) + } + const vm = getCurrentInstance() if (!vm) { return } onBeforeUnmount(() => { head.removeHeadObjs(headObj) + head.updateDOM() }) }