【问题标题】:how to do while with promise? [duplicate]有诺言怎么办? [复制]
【发布时间】:2015-11-01 10:57:56
【问题描述】:

我有与 promise 的逻辑,如果它找到它,它会使用 name 在它调用它的第一个承诺之后的问题并没有继续到下一个时间并从函数返回。 什么是拧?

       var result = true;
       var that = this;
       var name = "testFoler";
       while (result) {
            var index = 0;
            return that.context.doPromise(name).then(function(promiseResult) {
                if (promiseResult === null){
                    return Q(name)
                } else {
                    index++;
                    name = name + index
                }
            });

       }

【问题讨论】:

    标签: javascript q


    【解决方案1】:

    嗯,您将“reuslt”作为参数传递,这肯定不存在。

    【讨论】:

    • 这无关紧要,OP有一个实际问题。
    • 这当然是相关的。
    • 对不起我的错误我修复了它导致它只是从循环
    • @Andy 拼写错误无关紧要
    • 如果拼写错误导致代码无法继续运行,该怎么办?
    猜你喜欢
    • 1970-01-01
    • 2011-11-07
    • 2017-01-12
    • 2012-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 2012-04-14
    相关资源
    最近更新 更多