Appearance
getParentInstance
▸ getParentInstance(options
, instance?
): void
| ComponentInternalInstance
通过 name、ID、Ref 或组件名称多种方式获取父级实例
参数
Name | Type | Description |
---|---|---|
options | Object | 选项对象,包含要查询的属性和名称,任选其一即可 |
options.componentName | undefined | string | 组件名称 |
options.id | undefined | string | 组件ID |
options.name | undefined | string | 组件名称 |
options.ref | undefined | string | 组件Ref |
instance? | ComponentInternalInstance | 当前实例 |
返回值
void
| ComponentInternalInstance
父级组件实例
示例
ts
const parentInstance = getParentInstance({
componentName: 'share-root',
})
const parentInstance = getParentInstance({
id: 'share-root',
})