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

fix(mp-baidu): Retry three times to get refs (#3615)

上级 5831bdcb
...@@ -4820,12 +4820,18 @@ function setRef(instance, isUnmount = false) { ...@@ -4820,12 +4820,18 @@ function setRef(instance, isUnmount = false) {
return false; return false;
}); });
}; };
const retry = (refs, count = 3, timeout = 20) => {
setTimeout(() => {
refs = doSetByRefs(refs);
if (refs.length && count > 1) {
retry(refs, count - 1);
}
}, timeout);
};
const doSet = () => { const doSet = () => {
const refs = doSetByRefs($templateRefs); const refs = doSetByRefs($templateRefs);
if (refs.length) { if (refs.length) {
setTimeout(() => { retry(refs);
doSetByRefs(refs);
}, 10);
} }
}; };
if ($scope._$setRef) { if ($scope._$setRef) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册