findVueComponent

2020/12/28

获取 vue 子组件

findVueComponent(context, componentName, cb)

# 参数

  1. context (this.$root) :vue 根实例
  2. componentName (String) :查找组件名称,name 值
  3. cb ((childComp) => Boolean) :精确查找的条件函数。默认是 (comp) => true,如果自定义传入在 componentName 匹配上的同时要满足 cb 返回 true

# 返回值

(VNode) :vue 组件实例

# 例子

import { findVueComponent } from '@liz-q/utils'

const ListComp = findVueComponent(this.$root, 'List')

const DetailComp = findVueComponent(this.$root, 'Detail', (comp) => {
    // ...
    return true
})
Last Updated: 2023/11/13 下午5:46:22