diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index bbce72906a..241352df6d 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -375,7 +375,9 @@ export function useAsyncData< const hasScope = getCurrentScope() if (options.watch) { const unsub = watch(options.watch, () => asyncData.refresh()) - if (hasScope) { + if (instance) { + onUnmounted(unsub) + } else if (hasScope) { onScopeDispose(unsub) } } @@ -384,7 +386,9 @@ export function useAsyncData< await asyncData.refresh() } }) - if (hasScope) { + if (instance) { + onUnmounted(off) + } else if (hasScope) { onScopeDispose(off) } }