现在的位置: 首页 > 综合 > 正文

Seajs的简单使用示例:

2013年05月12日 ⁄ 综合 ⁄ 共 362字 ⁄ 字号 评论关闭

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();
        });

 

 

 

抱歉!评论已关闭.