fix: result

This commit is contained in:
Julien Huang 2024-08-23 00:14:54 +02:00
parent 47ac6bb843
commit 1ac48fe0b7

View File

@ -48,7 +48,7 @@ export const defineNuxtComponent: typeof defineComponent =
...options, ...options,
setup (props, ctx) { setup (props, ctx) {
const res = setup ? setup(props, ctx) : {} const res = setup ? setup(props, ctx) : {}
const result = Promise.resolve(res).then(() => res || {})
const promises: Promise<any>[] = [] const promises: Promise<any>[] = []
if (options.asyncData) { if (options.asyncData) {
promises.push(runLegacyAsyncData(res, options.asyncData)) promises.push(runLegacyAsyncData(res, options.asyncData))
@ -59,9 +59,9 @@ export const defineNuxtComponent: typeof defineComponent =
useHead(typeof options.head === 'function' ? () => options.head(nuxtApp) : options.head) useHead(typeof options.head === 'function' ? () => options.head(nuxtApp) : options.head)
} }
return Promise.resolve(res) return Promise.resolve(result)
.then(() => Promise.all(promises)) .then(() => Promise.all(promises))
.then(() => res) .then(() => result)
.finally(() => { .finally(() => {
promises.length = 0 promises.length = 0
}) })