mirror of https://github.com/nuxt/nuxt.git
fix: wrap legacyasyncdata with runWithCOntext
This commit is contained in:
parent
3161c1545e
commit
2a47785ddd
|
@ -47,10 +47,11 @@ export const defineNuxtComponent: typeof defineComponent =
|
||||||
_fetchKeyBase: key,
|
_fetchKeyBase: key,
|
||||||
...options,
|
...options,
|
||||||
setup (props, ctx) {
|
setup (props, ctx) {
|
||||||
|
const nuxtApp = useNuxtApp()
|
||||||
const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {}
|
const res = setup ? Promise.resolve(setup(props, ctx)).then(r => r || {}) : {}
|
||||||
const promises: Promise<any>[] = []
|
const promises: Promise<any>[] = []
|
||||||
if (options.asyncData) {
|
if (options.asyncData) {
|
||||||
promises.push(runLegacyAsyncData(res, options.asyncData))
|
promises.push(nuxtApp.runWithContext(() => runLegacyAsyncData(res, options.asyncData)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.head) {
|
if (options.head) {
|
||||||
|
|
Loading…
Reference in New Issue