Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 6e10521

Browse files
committed
v2.0.1-beta
1 parent 9b9ee9a commit 6e10521

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

dist/index.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ const loader = {
454454
return list;
455455
});
456456
},
457-
loadScript: function (el, path) {
457+
loadScript: function (el, url) {
458458
return new Promise(function (resolve) {
459459
let script = document.createElement('script');
460460
script.addEventListener('load', function () {
@@ -463,10 +463,37 @@ const loader = {
463463
script.addEventListener('error', function () {
464464
resolve(false);
465465
});
466-
script.src = path;
466+
script.src = url;
467467
el.appendChild(script);
468468
});
469469
},
470+
loadScripts: function (el, urls, opt = {}) {
471+
return new Promise((resolve) => {
472+
let count = 0;
473+
for (let url of urls) {
474+
this.loadScript(el, url).then(function (res) {
475+
var _a, _b;
476+
++count;
477+
if (res) {
478+
(_a = opt.loaded) === null || _a === void 0 ? void 0 : _a.call(opt, url, 1);
479+
}
480+
else {
481+
(_b = opt.loaded) === null || _b === void 0 ? void 0 : _b.call(opt, url, 0);
482+
}
483+
if (count === urls.length) {
484+
resolve();
485+
}
486+
}).catch(function () {
487+
var _a;
488+
++count;
489+
(_a = opt.loaded) === null || _a === void 0 ? void 0 : _a.call(opt, url, -1);
490+
if (count === urls.length) {
491+
resolve();
492+
}
493+
});
494+
}
495+
});
496+
},
470497
import: function (url, files, executedFiles, opt = {}) {
471498
return __awaiter(this, void 0, void 0, function* () {
472499
if (opt.dir === undefined) {

0 commit comments

Comments
 (0)