Skip to content

Instantly share code, notes, and snippets.

@mockee
Created Sep 10, 2012
Embed
What would you like to do?
// 支持自定义命名空间
Do.setConfig('namespace', 'Ark');
// 利用 `Do` 自身的 `add` 来定义模块的方法名
Do.add('cookie', { path: 'cookie.js' });
Do.add('ajax', { path: 'ajax.js', requires:['cookie'] });
Do('ajax', function() {
console.info(Ark.ajax); // Using ajax with cookie mod.
});
// cookie module
define('mods/cookie', function() {
return function() {
return 'cookie mod';
};
});
// ajax module
define('mods/ajax', ['mods/cookie'], function(cookie) {
return function() {
return 'Using ajax with ' + cookie();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment