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