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

fix(mp-weixin): findVmByVueId #1200

上级 355e0efa
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册