UNPKG

song-ui-u

Version:

vue3 + js的PC前端组件库

35 lines (32 loc) 908 B
import { getCurrentInstance } from 'vue'; import { defaultNamespace } from '../config.mjs'; const useParent = (parentName) => { const parent = getCurrentInstance().parent; const group = () => { return parent.proxy.$options.name === `${defaultNamespace}-${parentName}`; }; const getParent = (data) => { let parentComponent = null; const getComponent = (parent2) => { const name = parent2?.proxy?.$options?.name; const pName = `${defaultNamespace}-${parentName}`; if (name === pName) { parentComponent = parent2; return false; } parent2.parent && getComponent(parent2.parent); }; getComponent(data); return parentComponent; }; const props = (attr) => { const p = getParent(parent); return p?.props?.[attr] || false; }; return { group, props }; }; export { useParent }; //# sourceMappingURL=index.mjs.map