define: 定义模块
require: 加载模块
//A.js 普通模块定义
Salut.define(function(){
var a = this.require('js/B');
return { A: a };
});
//B.js 声明模块名称b
Salut.define('B', function(){
var b = this.require('js/C');
return { B: b };
});
//C.js 未生命模块名称 提前声明了模块的依赖D
Salut.define(['D'], function(){
return { hello: 'world' };
});
//D.js 提前声明多个模块依赖以及 在函数体内生命模块
Salut.define(['A', 'D'],function(){
return this.require('js/B');
});
//main.js
Salut.require('js/A', function(a){
console.log(a);
});