You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
739 B
32 lines
739 B
function findVmById (id, vm) {
|
|
if (id === vm._$id) {
|
|
return vm
|
|
}
|
|
const childVms = vm.$children
|
|
const len = childVms.length
|
|
for (let i = 0; i < len; i++) {
|
|
const childVm = findVmById(id, childVms[i])
|
|
if (childVm) {
|
|
return childVm
|
|
}
|
|
}
|
|
}
|
|
|
|
export function findElm (component, pageVm) {
|
|
if (!pageVm) {
|
|
return console.error('page is not ready')
|
|
}
|
|
if (!component) {
|
|
return pageVm.$el
|
|
}
|
|
if (__PLATFORM__ === 'app-plus') {
|
|
if (typeof component === 'string') {
|
|
const componentVm = findVmById(component, pageVm)
|
|
if (!componentVm) {
|
|
throw new Error(`Not Found:Page[${pageVm.$page.id}][${component}]`)
|
|
}
|
|
return componentVm.$el
|
|
}
|
|
}
|
|
return component.$el
|
|
}
|
|
|