财务表单关联系统

ceshi.html 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. </body>
  11. <script>
  12. let orderTagList = [1,2]
  13. let abb = {a:1}
  14. let acc = {b:2}
  15. Promise.prototype._all = function(promises) {
  16. let results = [];
  17. let promiseCount = 0;
  18. let promisesLength = promises.length;
  19. return new Promise(function(resolve, reject) {
  20. for (let val of promises) {
  21. Promise.resolve(val).then(function(res) {
  22. console.log(res)
  23. promiseCount++;
  24. results.push({a:res});
  25. // results[i] = res;
  26. // 当所有函数都正确执行了,resolve输出所有返回结果。
  27. if (promiseCount === promisesLength) {
  28. return resolve(results);
  29. }
  30. }, function(err) {
  31. return reject(err);
  32. });
  33. }
  34. });
  35. };
  36. Promise.prototype._all([orderTagList,abb,acc]).then((e)=>{
  37. console.log(e,'2');
  38. })
  39. </script>
  40. </html>