calling a function having callback in for loop

后端 未结 2 1143
失恋的感觉
失恋的感觉 2021-01-29 06:37

I want to run window.resolveLocalFileSystemURI(file,success,fail) in for loop passing different file entries and want to return resolved entries in arr

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 07:01

    this is all based on all your functions being synchronous, and if not: be more specific what you're using. (there is no jQuery here yet your tags say jquery)

    function resolveFile(path) {
        var result;
        window.resolveLocalFileSystemURI(path, function(file) {
            result = file;
        });
        return file;
    }
    var resolvedFiles = filesarr.map(resolveFile);
    callback(resolvedFiles);
    

提交回复
热议问题