fix: wrap legacyasyncdata with runWithCOntext

This commit is contained in:
Julien Huang 2024-08-24 17:27:27 +02:00
parent 3161c1545e
commit 2a47785ddd
1 changed files with 2 additions and 1 deletions

View File

@ -47,10 +47,11 @@ export const defineNuxtComponent: typeof defineComponent =
_fetchKeyBase: key,
...options,
setup (props, ctx) {
const nuxtApp = useNuxtApp()
const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {}
const promises: Promise<any>[] = []
if (options.asyncData) {
promises.push(runLegacyAsyncData(res, options.asyncData))
promises.push(nuxtApp.runWithContext(() => runLegacyAsyncData(res, options.asyncData)))
}
if (options.head) {