import { getCurrentInstance } from 'vue';

export default function () {
  const instance = getCurrentInstance();

  const findComponentsDownward = (componentName: string) => {
    console.log('instanceinstanceinstanceinstanceinstance :>> ', instance);
    // return context.$children.reduce((components, child) => {
    //   if (child.$options.name === componentName) components.push(child);
    //   const foundChilds = findComponentsDownward(child, componentName);
    //   return components.concat(foundChilds);
    // }, []);

    // 找出该组件下的所有是”组件“的组件
    instance?.subTree.children;
    return [];
  };
  return {
    findComponentsDownward
  };
}
