mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix: move back into Promise.resolve
This commit is contained in:
parent
1ac48fe0b7
commit
3161c1545e
@ -47,8 +47,7 @@ export const defineNuxtComponent: typeof defineComponent =
|
|||||||
_fetchKeyBase: key,
|
_fetchKeyBase: key,
|
||||||
...options,
|
...options,
|
||||||
setup (props, ctx) {
|
setup (props, ctx) {
|
||||||
const res = setup ? setup(props, ctx) : {}
|
const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {}
|
||||||
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 +58,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(result)
|
return Promise.resolve(res)
|
||||||
.then(() => Promise.all(promises))
|
.then(() => Promise.all(promises))
|
||||||
.then(() => result)
|
.then(() => res)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
promises.length = 0
|
promises.length = 0
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user