js 项目结构
<!DOCTYPE html> <html> <head> <title>Ready</title> </head> <body> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script type="text/javascript"> var designer = {}; //loader (function(loader){ var delayActions = []; function onReady(){ for (var i = 0; i < delayActions.length; i++) { delayActions[i](); } delayActions = []; } function ready(func) { console.log(func) delayActions.push(func); } loader.ready = ready; function loadContent(){ console.log("将各个html部分附加到html页面中") setTimeout(function(){ console.log("html加载完毕......开始执行初始化函数.....") onReady(); }, 1000) } loader.loadContent = loadContent; designer.loader = loader; })(designer.loader || ({})); //index (function(index){ $(document).ready(function () { console.log("初始化, 从这儿开始......"); designer.loader.loadContent(); }); designer.loader.ready(function(){ console.log("update layout index file") }) })(designer.index || ({})); //statusBar (function(statusBar){ designer.loader.ready(function(){ console.log("初始化 statusBar...........") }) })(designer.statusBar || ({})); //ribbon (function(ribbon){ designer.loader.ready(function(){ console.log("初始化 ribbon...........") }) })(designer.ribbon || ({})); //fileMenu (function(fileMenu){ designer.loader.ready(function(){ console.log("初始化 fileMenu...........") }) })(designer.fileMenu || ({})); </script> </body> </html>