mirror of
https://github.com/troisjs/trois.git
synced 2024-11-23 20:02:32 +08:00
script setup fix (#74)
This commit is contained in:
parent
89b649be12
commit
3ef40d5a06
@ -1,5 +1,5 @@
|
|||||||
import { Object3D, Scene } from 'three'
|
import { Object3D, Scene } from 'three'
|
||||||
import { ComponentPublicInstance, defineComponent, PropType, watch } from 'vue'
|
import { ComponentPublicInstance, defineComponent, getCurrentInstance, PropType, watch } from 'vue'
|
||||||
import { bindObjectProp, bindProp } from '../tools'
|
import { bindObjectProp, bindProp } from '../tools'
|
||||||
import { RendererInjectionKey, RendererInterface } from './Renderer'
|
import { RendererInjectionKey, RendererInterface } from './Renderer'
|
||||||
import { SceneInjectionKey } from './Scene'
|
import { SceneInjectionKey } from './Scene'
|
||||||
@ -125,6 +125,13 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
getParent(): undefined | ComponentPublicInstance {
|
getParent(): undefined | ComponentPublicInstance {
|
||||||
let parent = this.$parent
|
let parent = this.$parent
|
||||||
|
|
||||||
|
if (!parent) {
|
||||||
|
// for script setup
|
||||||
|
const instance = getCurrentInstance() as any // ctx is internal
|
||||||
|
if (instance && instance.parent) parent = instance.parent.ctx
|
||||||
|
}
|
||||||
|
|
||||||
while (parent) {
|
while (parent) {
|
||||||
if ((parent as any).add) return parent
|
if ((parent as any).add) return parent
|
||||||
parent = parent.$parent
|
parent = parent.$parent
|
||||||
|
Loading…
Reference in New Issue
Block a user