必须要先引入sea.js文件
<script src="js/sea.js"></script>
其次,引入其他js文件
1 <script> 2 seajs.config({ 3 alias: { 4 "layer": "layer/layer.js", 5 "jsRender": "jquery.jsRender.min.js", 6 "dataInfo": "dataInfo.js", 7 "WdatePicker":"My97DatePicker4.8/WdatePicker.js" 8 },preload:["layer","jsRender","dataInfo","WdatePicker"] 9 }); 10 seajs.use("changan.js"); 11 </script>
封装的js文件必须以define定义
1 define(function(){ 2 var mainMoudle={ 3 initEvent:function(){ 4 mainMoudle.query(); 5 }, 6 query:function(){ 7 //操作 8 }, 9 clickEvent:function(){ 10 $().click(function(){}); 11 } 12 main:function(){ 13 mainMoudle.initEvent(); 14 } 15 }; 16 $(function(){ 17 mainMoudle.main(); 18 }) 19 });
时间: 2024-10-10 00:47:57