mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
feat(bridge): allow accessing injections from useNuxtApp
(#1623)
This commit is contained in:
parent
47e0721413
commit
5aa33b807c
@ -14,7 +14,7 @@ export default (ctx, inject) => {
|
|||||||
mount: () => { },
|
mount: () => { },
|
||||||
provide: inject,
|
provide: inject,
|
||||||
unmount: () => { },
|
unmount: () => { },
|
||||||
use(vuePlugin) {
|
use (vuePlugin) {
|
||||||
vuePlugin.install(this)
|
vuePlugin.install(this)
|
||||||
},
|
},
|
||||||
version: Vue.version
|
version: Vue.version
|
||||||
@ -42,7 +42,16 @@ export default (ctx, inject) => {
|
|||||||
nuxtApp.vue2App = this
|
nuxtApp.vue2App = this
|
||||||
})
|
})
|
||||||
|
|
||||||
setNuxtAppInstance(nuxtApp)
|
const proxiedApp = new Proxy(nuxtApp, {
|
||||||
|
get (target, prop) {
|
||||||
|
if (prop[0] === '$') {
|
||||||
|
return target.nuxt2Context[prop] || target.vue2App?.[prop]
|
||||||
|
}
|
||||||
|
return Reflect.get(target, prop)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
inject('_nuxtApp', nuxtApp)
|
setNuxtAppInstance(proxiedApp)
|
||||||
|
|
||||||
|
inject('_nuxtApp', proxiedApp)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user