此代码未取消请求,为什么?

RestangularConfigurer.addFullRequestInterceptor(function (element, operation, route, url, headers, params, httpConfig) {
    var defer = $q.defer();
    defer.reject();
    httpConfig.timeout = defer;
    return {
        element: element,
        headers: headers,
        params: params,
        httpConfig: httpConfig
    };
});

最佳答案

您应该为超时分配一个承诺:

httpConfig.timeout = defer.promise;


并解决它(不拒绝):

defer.resolve();

关于javascript - 我如何取消之前的请求发送矩形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21981432/

10-12 13:03