mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +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)
|
||||
|
||||
if (process.client) {
|
||||
window.onNuxtReady(() => {
|
||||
nuxtApp.hooks.callHook('app:mounted', nuxtApp.vueApp)
|
||||
})
|
||||
}
|
||||
|
||||
inject('_nuxtApp', proxiedApp)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
const head = createHead()
|
||||
|
||||
nuxtApp.vueApp.use(head)
|
||||
nuxtApp.hooks.hookOnce('app:mounted', () => { watchEffect(() => head.updateDOM()) })
|
||||
|
||||
nuxtApp._useMeta = (meta: MetaObject) => {
|
||||
const headObj = ref(meta as any)
|
||||
@ -14,16 +15,11 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
|
||||
if (process.server) { return }
|
||||
|
||||
watchEffect(() => {
|
||||
head.updateDOM()
|
||||
})
|
||||
|
||||
const vm = getCurrentInstance()
|
||||
if (!vm) { return }
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
head.removeHeadObjs(headObj)
|
||||
head.updateDOM()
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user