mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): prefer nuxt app context over getCurrentInstance
(#5456)
This commit is contained in:
parent
2fa0248cab
commit
d7d97cd7d1
@ -236,17 +236,17 @@ export function callWithNuxt<T extends (...args: any[]) => any> (nuxt: NuxtApp |
|
||||
* Returns the current Nuxt instance.
|
||||
*/
|
||||
export function useNuxtApp () {
|
||||
const vm = getCurrentInstance()
|
||||
const nuxtAppInstance = nuxtAppCtx.use()
|
||||
|
||||
if (!vm) {
|
||||
const nuxtAppInstance = nuxtAppCtx.use()
|
||||
if (!nuxtAppInstance) {
|
||||
if (!nuxtAppInstance) {
|
||||
const vm = getCurrentInstance()
|
||||
if (!vm) {
|
||||
throw new Error('nuxt instance unavailable')
|
||||
}
|
||||
return nuxtAppInstance
|
||||
return vm.appContext.app.$nuxt as NuxtApp
|
||||
}
|
||||
|
||||
return vm.appContext.app.$nuxt as NuxtApp
|
||||
return nuxtAppInstance
|
||||
}
|
||||
|
||||
export function useRuntimeConfig (): RuntimeConfig {
|
||||
|
Loading…
Reference in New Issue
Block a user