异步加载js,兼容IE
let loadScript = function (url,callback) { let script = document.createElement('script'); script.type = "text/javascript"; if(script.readyState){ //ie script.onreadystatechange = function () { if(script.readyState == "complete" || script.readyState == "loaded"){ tools[callback](); } } }else { script.onload = function () { tools[callback](); } } script.src = url; document.head.appendChild(script); } loadScript("demo.js",'test')
//demo.js
let tools = { test : function () { console.log('a'); } }