const appjs = (callback,url) => {
var scripts = [url];
var HEAD =
document.getElementsByTagName("head").item(0) ||
document.documentElement;
var s = new Array(),
last = scripts.length - 1,
recursiveLoad = function (i) {
console.log('recursiveLoad中的this',this);
//递归
s[i] = document.createElement("script");
s[i].setAttribute("type", "text/javascript");
s[i].onload = s[i].onreadystatechange = function () {
console.log('onreadystatechange中的this',this);
//Attach handlers for all browsers
if (
!/*@cc_on!@*/ 0 ||
this.readyState == "loaded" ||
this.readyState == "complete"
) {
this.onload = this.onreadystatechange = null;
this.parentNode.removeChild(this);
if (i != last) recursiveLoad(i + 1);
else if (typeof callback == "function") {
callback();
}
}
};
s[i].setAttribute("src", scripts[i]);
HEAD.appendChild(s[i]);
};
recursiveLoad(0);
}
export default appjs