@tuoyuan/map-adapter-lib
Version:
地图适配器库
29 lines (28 loc) • 1.03 kB
JavaScript
function i(o) {
return new Promise(function(n, r) {
const t = document.createElement("script");
t.type = "text/javascript";
let e = o;
if (typeof e.content == "string")
return t.text = e.content, document.head.appendChild(t), t.onerror = r, n();
e = o, typeof e.url == "string" && (t.src = e.url), typeof e.async == "boolean" && (t.async = e.async), typeof e.integrity == "string" && (t.integrity = e.integrity, t.setAttribute("crossorigin", "anonymous")), t.onerror = r, document.head.appendChild(t), t.onload = () => {
n();
}, t.addEventListener("error", r), t.addEventListener("load", () => {
n();
});
});
}
function d(o) {
return new Promise(function(n, r) {
const t = document.createElement("link");
t.rel = "stylesheet", t.type = "text/css", t.href = o.url, document.head.appendChild(t), t.onload = () => {
n();
}, t.addEventListener("error", r), t.addEventListener("load", () => {
n();
});
});
}
export {
d as loadCSS,
i as loadScript
};