提交 79e8ed95 编写于 作者: fxy060608's avatar fxy060608

fix(v3): requestComponentInfo(app-plus)

上级 f0ec1e1b
...@@ -12616,19 +12616,38 @@ function getNodeInfo(el, fields) { ...@@ -12616,19 +12616,38 @@ function getNodeInfo(el, fields) {
return info; return info;
} }
function findElm(id, vm) {
if (id === vm._$id) {
return vm;
}
var childVms = vm.$children;
var len = childVms.length;
for (var i = 0; i < len; i++) {
var childVm = findElm(id, childVms[i]);
if (childVm) {
return childVm;
}
}
}
function getElm(component, pageVm) { function getElm(component, pageVm) {
if (!component) { if (!component) {
return pageVm.$el; return pageVm.$el;
} }
if (typeof component === 'string') { if (true) {
var componentVm = pageVm._$vd.getVm(component); if (typeof component === 'string') {
var componentVm = findElm(component, pageVm);
if (!componentVm) {
throw new Error("Not Found\uFF1APage[".concat(pageVm.$page.id, "][").concat(component, "]"));
}
if (!componentVm) { return componentVm.$el;
throw new Error("Not Found\uFF1APage[".concat(pageVm.$page.id, "][").concat(component, "]"));
} }
return componentVm.$el;
} }
return component.$el; return component.$el;
......
...@@ -73,16 +73,32 @@ function getNodeInfo (el, fields) { ...@@ -73,16 +73,32 @@ function getNodeInfo (el, fields) {
return info return info
} }
function findElm (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 = findElm(id, childVms[i])
if (childVm) {
return childVm
}
}
}
function getElm (component, pageVm) { function getElm (component, pageVm) {
if (!component) { if (!component) {
return pageVm.$el return pageVm.$el
} }
if (typeof component === 'string') { if (__PLATFORM__ === 'app-plus') {
const componentVm = pageVm._$vd.getVm(component) if (typeof component === 'string') {
if (!componentVm) { const componentVm = findElm(component, pageVm)
throw new Error(`Not Found:Page[${pageVm.$page.id}][${component}]`) if (!componentVm) {
throw new Error(`Not Found:Page[${pageVm.$page.id}][${component}]`)
}
return componentVm.$el
} }
return componentVm.$el
} }
return component.$el return component.$el
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册