diff --git a/src/platforms/mp-weixin/runtime/wrapper/util.js b/src/platforms/mp-weixin/runtime/wrapper/util.js index 926f4d09e8bb26405ae1bdb228c66cff9ba63d37..079e7f58e41508e61de4ba8e3d2dcb8b821dfa32 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/util.js +++ b/src/platforms/mp-weixin/runtime/wrapper/util.js @@ -2,12 +2,15 @@ export const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'] export function findVmByVueId (vm, vuePid) { const $children = vm.$children - // 优先查找直属 - let parentVm = $children.find(childVm => childVm.$scope._$vueId === vuePid) - if (parentVm) { - return parentVm + // 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200) + for (let i = $children.length - 1; i >= 0; i--) { + const childVm = $children[i] + if (childVm.$scope._$vueId === vuePid) { + return childVm + } } // 反向递归查找 + let parentVm for (let i = $children.length - 1; i >= 0; i--) { parentVm = findVmByVueId($children[i], vuePid) if (parentVm) {