mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +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 { ref, watchEffect, onBeforeUnmount } from 'vue'
|
||||
import { ref, watchEffect, onBeforeUnmount, getCurrentInstance } from 'vue'
|
||||
import type { MetaObject } from '..'
|
||||
import { defineNuxtPlugin } from '#app'
|
||||
|
||||
@ -18,6 +18,9 @@ export default defineNuxtPlugin((nuxt) => {
|
||||
head.updateDOM()
|
||||
})
|
||||
|
||||
const vm = getCurrentInstance()
|
||||
if (!vm) { return }
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
head.removeHeadObjs(headObj)
|
||||
head.updateDOM()
|
||||
|
Loading…
Reference in New Issue
Block a user