seajs使用方法
必须执行seajs.use()时,才能自动执行预加载项
<script src="/UILib/sea.js"></script> <script src="/UILib/seajs-preload.js"></script> <%--<script src="/UILib/seajs-css.js"></script>--%> <script type="text/javascript"> (function () { var modConfig = { "AppVer": "1.1.5", //应用版本 "base": "/UILib/", //Sea.js 的基础路径 "alias": { "jquery": "/UILib/EasyUI/jquery.min",// 别名配置 可以让文件的真实路径与调用标识分开,有利于统一维护。 "EasyUI": 'EasyUI/jquery.easyui.min', "EasyUI-lang": 'EasyUI/locale/easyui-lang-zh_CN', "Wdate": 'WdatePicker/WdatePicker', "artDialog": 'artDialog/artDialog.source', "iframeTools": 'artDialog/iframeTools.source', "jqGrid-lang": '/Scripts/jqGrid/js/i18n/grid.locale-en', "jqGrid": '/Scripts/jqGrid/js/jquery.jqGrid.min', 'seajs-css':'seajs-css' }, "debug": false // 是否启用调试模式 }; var mapVer = function (str) { str = str + "?v=" + modConfig.AppVer; return str; }; seajs.config({ base: modConfig.base, alias: modConfig.alias, preload: [ // 预加载项 "seajs-css", "jquery", "Wdate", "artDialog", "EasyUI", ], debug: modConfig.debug || 0, map: [[/.*\.js$/, mapVer]], // 映射配置 charset: 'UTF-8' //// 文件编码 }); // 加载入口模块 seajs.use([ "EasyUI-lang","iframeTools", "jqGrid-lang", "jqGrid", '/Scripts/Common/Utils.js'], function () { seajs.use([]); //seajs.use(["iframeTools"]); var bootstrap = ['/Scripts/jqGrid/css/jquery-ui.css', '/Scripts/jqGrid/css/ui.jqgrid.css', '/RMCS/Script/YCGK/OperationLog.js']; seajs.use(bootstrap, function () { //do something }); }); //seajs.use("main1"); })(); </script>
此框架与requirejs类似,主要是模式不同,Seajs为CMD懒加载模式,requirejs为AMD异步加载。