first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { selectComponent } from './select-component';
|
||||
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user