Melchior.jsJavaScript 模塊加載器
Melchior.js 是一個(gè)模式加載器,提供通過鏈?zhǔn)侥K定義的API,讓你可以遠(yuǎn)離那些長長的AMD定義和重復(fù)的模塊名。它起步非常容易,定制方便,而且壓縮版只有3KB。
在線演示
示例代碼:
// create modulemelchiorjs.module('yourModule')// define dependencies.require('dependencyUno')
.require('dependencyDuo', 'duo')// define module body.body(function () { // `dependencyUno` is available here!
dependencyUno.doSomething(); // aliased `dependencyDuo` is available as `duo`!
duo.doSomething(); // return methods for other modules
return {
method: function () { ... },
anotherMethod: function () { ... }
};
});
配置:
melchiorjs.config({
paths: { 'jQuery': 'path/to/jquery', 'underscore': 'path/to/underscore', 'myModule': 'path/to/myModule'
}, // provide shim to non-melchior modules if needed
// declare globals returned by libraries and deps
shim: {
underscore: {
exports: '_'
}
}
});
支持的瀏覽器:
| 1+ ? | 2+ ? | 8+ ? | 10+ ? | 3+ ? |
評(píng)論
圖片
表情
