Seajs的简单使用示例:

1、定义模块<在JS中定义>

define('./dom', [], function(require, exports, module) {
                var mod;             
                return mod = {
                    'a' : function() {
                        alert('a');
                    },
                    'b' : function() {
                        alert('b');
                   }
               };
           })
           或者
            define(function(require, exports, module) {//or define([], function(require, exports, module) {        
                exports.a = function() {
                    alert('dom-a');
                };     
                exports.b = function() {
                    alert('dom-b');
               };   
          });

2、使用模块

seajs.use('./dom', function(dom) {
            dom.a();
        });

 

 

 

posted @ 2012-09-17 13:33  microsoftzhcn  阅读(301)  评论(0编辑  收藏  举报