【发布时间】:2019-05-31 13:50:21
【问题描述】:
我在等待我的 forEach 循环完成时遇到了问题,该循环内部有一个承诺。我找不到任何真正的解决方案,这会使脚本等到最后,然后再继续执行。我无法使 someFunction 同步。
makeTree: function (arr) {
arr.forEach(function (resource) {
someModule.someFunction(resource).then(function () { //a Promise
//do something with the resource that has been modified with someFunction
});
});
// do something after the loop finishes
}
【问题讨论】:
-
你在用 angularjs 吗?
标签: javascript