mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(nuxt3): prevent removing and re-adding tags before mount (#3212)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
6a93719a89
commit
ef69e746d2
@ -77,5 +77,11 @@ export default (ctx, inject) => {
|
|||||||
|
|
||||||
setNuxtAppInstance(proxiedApp)
|
setNuxtAppInstance(proxiedApp)
|
||||||
|
|
||||||
|
if (process.client) {
|
||||||
|
window.onNuxtReady(() => {
|
||||||
|
nuxtApp.hooks.callHook('app:mounted', nuxtApp.vueApp)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
inject('_nuxtApp', proxiedApp)
|
inject('_nuxtApp', proxiedApp)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const head = createHead()
|
const head = createHead()
|
||||||
|
|
||||||
nuxtApp.vueApp.use(head)
|
nuxtApp.vueApp.use(head)
|
||||||
|
nuxtApp.hooks.hookOnce('app:mounted', () => { watchEffect(() => head.updateDOM()) })
|
||||||
|
|
||||||
nuxtApp._useMeta = (meta: MetaObject) => {
|
nuxtApp._useMeta = (meta: MetaObject) => {
|
||||||
const headObj = ref(meta as any)
|
const headObj = ref(meta as any)
|
||||||
@ -14,16 +15,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
|
|
||||||
if (process.server) { return }
|
if (process.server) { return }
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
head.updateDOM()
|
|
||||||
})
|
|
||||||
|
|
||||||
const vm = getCurrentInstance()
|
const vm = getCurrentInstance()
|
||||||
if (!vm) { return }
|
if (!vm) { return }
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
head.removeHeadObjs(headObj)
|
head.removeHeadObjs(headObj)
|
||||||
head.updateDOM()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user