Files
mini-yu/uni_modules/tdesign-uniapp/components/common/dom/select-component.js

27 lines
595 B
JavaScript
Raw Normal View History

2026-02-10 08:05:03 +08:00
export function selectComponent(context, selector) {
if (!selector || !context) return;
if (typeof selector === 'function') {
return selector(context);
}
let attribute = selector;
if (attribute.match(/^[^\w]/)) {
attribute = attribute.slice(1);
}
if (
context.$refs && context.$refs[attribute]) {
return context.$refs[attribute];
}
if (context && typeof context.$selectComponent === 'function') {
const res = context.$selectComponent(selector);
return res;
}
return context && context.selectComponent && context.selectComponent(selector);
}