标签:
var workAsync = function() { var p = new Promise(function(resolve, rej) { $.get("http://....", function(rs){ resolve("dddddddd"); }) }); return p; } workAsync().then(function(data) { console.log(data); });
var p1 = Promise.resolve(3); var p2 = Promise.resolve(999); Promise.all([p1, p2]).then(function(values) { console.log(values); // [3, 999] });
var workAsync = function(url) { var p = new Promise(function(resolve, rej) { $.get(url, function(rs){ resolve("dddddddd"); }) }); return p; } var tasks = []; tasks.push(workAsync("http://1....")); tasks.push(workAsync("http://2....")); Promise.all(tasks).then(function(values) { console.log(values); // [...] });
标签:
原文地址:http://www.cnblogs.com/eturn/p/4559651.html