欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Seajs的简单使用示例:

程序员文章站 2024-03-26 12:28:17
...

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

 

 

 


更多专业前端知识,请上【猿2048】www.mk2048.com
相关标签: seajs