mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 06:31:27 +00:00
fix(nuxt3): don't call lifecycle methods outside of component (#675)
This commit is contained in:
parent
ac16127a13
commit
4b3814a14f
@ -1,5 +1,5 @@
|
|||||||
import { createHead, renderHeadToString } from '@vueuse/head'
|
import { createHead, renderHeadToString } from '@vueuse/head'
|
||||||
import { ref, watchEffect, onBeforeUnmount } from 'vue'
|
import { ref, watchEffect, onBeforeUnmount, getCurrentInstance } from 'vue'
|
||||||
import type { MetaObject } from '..'
|
import type { MetaObject } from '..'
|
||||||
import { defineNuxtPlugin } from '#app'
|
import { defineNuxtPlugin } from '#app'
|
||||||
|
|
||||||
@ -18,6 +18,9 @@ export default defineNuxtPlugin((nuxt) => {
|
|||||||
head.updateDOM()
|
head.updateDOM()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const vm = getCurrentInstance()
|
||||||
|
if (!vm) { return }
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
head.removeHeadObjs(headObj)
|
head.removeHeadObjs(headObj)
|
||||||
head.updateDOM()
|
head.updateDOM()
|
||||||
|
Loading…
Reference in New Issue
Block a user