提交 5eb082c7 编写于 作者: Q qiang

Merge branch 'nvue-dev' of github.com:dcloudio/uni-app into nvue-dev

...@@ -46,26 +46,22 @@ export function invokeVmMethod (vm, method, args, extras) { ...@@ -46,26 +46,22 @@ export function invokeVmMethod (vm, method, args, extras) {
} }
export function findElmById (id, vm) { export function findElmById (id, vm) {
return findElmByVNode(id, vm._vnode) return findRefByElm(id, vm.$el)
} }
function findElmByVNode (id, vnode) { function findRefByElm (id, elm) {
if (!id || !vnode) { if (!id || !elm) {
return return
} }
if ( if (elm.attr.id === id) {
vnode.data && return elm
vnode.data.attrs &&
vnode.data.attrs.id === id
) {
return vnode.elm
} }
const children = vnode.children const children = elm.children
if (!children) { if (!children) {
return return
} }
for (let i = 0, len = children.length; i < len; i++) { for (let i = 0, len = children.length; i < len; i++) {
const elm = findElmByVNode(id, children[i]) const elm = findRefByElm(id, children[i])
if (elm) { if (elm) {
return elm return elm
} }
...@@ -112,4 +108,4 @@ function normalizeCallback (method, callbacks) { ...@@ -112,4 +108,4 @@ function normalizeCallback (method, callbacks) {
isFn(complete) && complete(ret) isFn(complete) && complete(ret)
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册