js根据顺序加载,有依赖关系

 

function loadScript(url, callback) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
document.getElementById("srciptCode").appendChild(script);
script.onload = function() {
callback();
}
}
loadScript("../js/jquery-1.8.3.min.js",function(){
console.log("jquery-1.8.3.min.js ok")
loadScript("../js/jquery.qrcode.min.js",function(){
console.log("jquery.qrcode.min.js ok")
loadScript("../js/ui.min.js?0107",function(){
console.log("ui.min.js ok")
loadScript("../js/activity/code.min.js?0107",function(){
console.log("code.min.js ok")
})
})
})
})
posted @ 2019-01-07 13:53  暖爱  阅读(976)  评论(0编辑  收藏  举报