依赖加载简单实现方式
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")
})
})
})
})
来源:oschina
链接:https://my.oschina.net/u/4315672/blog/4273164